Difference between revisions of "NML:Replace TTD sprites"

From GRFSpecs
Jump to navigationJump to search
m (no need to preselect the biggest file and making loading of the page that long)
(Document the use of a block name for the replace and base_graphics block)
Line 3: Line 3:
 
Using a <code style="color:darkgreen">replace</code> block, it is possible to replace TTD's built-in sprites or for base grfs to define sprites via the <code style="color:darkgreen">base_graphics</code> block. The syntax is as follows:
 
Using a <code style="color:darkgreen">replace</code> block, it is possible to replace TTD's built-in sprites or for base grfs to define sprites via the <code style="color:darkgreen">base_graphics</code> block. The syntax is as follows:
   
replace(&lt;sprite-id&gt;, &lt;image-file&gt;) {
+
replace [&lt;block_name&gt;](&lt;sprite-id&gt;, &lt;image-file&gt;) {
 
[[#real sprites|list of realsprites]]
 
[[#real sprites|list of realsprites]]
 
}
 
}
Line 9: Line 9:
 
and
 
and
   
base_graphics(&lt;sprite-id&gt;, &lt;image-file&gt;) {
+
base_graphics [&lt;block_name&gt;](&lt;sprite-id&gt;, &lt;image-file&gt;) {
 
[[#real sprites|list of realsprites]]
 
[[#real sprites|list of realsprites]]
 
}
 
}
   
 
respectively
 
respectively
  +
  +
A <code style="color:darkgreen">&lt;block_name&gt;</code> is optional but required, if you want to define [[NML:Alternative sprites|alternative sprites]] for the sprite block so that it can be referenced there.
   
 
The first parameter <code style="color:darkgreen">&lt;sprite-id&gt;</code> indicates the sprite number of the first sprite to replace. Sprite numbers are equal to the sprite numbers in the base graphics file. The [http://mz.openttdcoop.org/opengfx/authors/script.php?feature=spritesbyfile&q= OpenGFX author overview] can be used as a reference to look up these sprite numbers. The second parameter <code style="color:darkgreen">&lt;image-file&gt;</code> specifies the image file that contains the new sprites. A series of real sprites has to be specified between the curly braces (<code style="color:darkgreen">{</code> and <code style="color:darkgreen">}</code>). The first sprite in this list replaces the sprite with id <code style="color:darkgreen">sprite-id</code>, the second replaces <code style="color:darkgreen">sprite-id + 1</code> and so on. Sprite templates can be used as well. For example:
 
The first parameter <code style="color:darkgreen">&lt;sprite-id&gt;</code> indicates the sprite number of the first sprite to replace. Sprite numbers are equal to the sprite numbers in the base graphics file. The [http://mz.openttdcoop.org/opengfx/authors/script.php?feature=spritesbyfile&q= OpenGFX author overview] can be used as a reference to look up these sprite numbers. The second parameter <code style="color:darkgreen">&lt;image-file&gt;</code> specifies the image file that contains the new sprites. A series of real sprites has to be specified between the curly braces (<code style="color:darkgreen">{</code> and <code style="color:darkgreen">}</code>). The first sprite in this list replaces the sprite with id <code style="color:darkgreen">sprite-id</code>, the second replaces <code style="color:darkgreen">sprite-id + 1</code> and so on. Sprite templates can be used as well. For example:
Line 19: Line 21:
 
<pre style="color:blue">
 
<pre style="color:blue">
 
// Rail overlays for crossings
 
// Rail overlays for crossings
replace (1005, "src/gfx/rails_overlays.png") {
+
replace rail_overlays(1005, "src/gfx/rails_overlays.png") {
 
[ 20,198, 40,21, -20, 5]
 
[ 20,198, 40,21, -20, 5]
 
[ 71,198, 40,21, -20, 5]
 
[ 71,198, 40,21, -20, 5]

Revision as of 08:24, 2 March 2012

Block Syntax

Using a replace block, it is possible to replace TTD's built-in sprites or for base grfs to define sprites via the base_graphics block. The syntax is as follows:

replace [<block_name>](<sprite-id>, <image-file>) {
	list of realsprites
}

and

base_graphics [<block_name>](<sprite-id>, <image-file>) {
	list of realsprites
}

respectively

A <block_name> is optional but required, if you want to define alternative sprites for the sprite block so that it can be referenced there.

The first parameter <sprite-id> indicates the sprite number of the first sprite to replace. Sprite numbers are equal to the sprite numbers in the base graphics file. The OpenGFX author overview can be used as a reference to look up these sprite numbers. The second parameter <image-file> specifies the image file that contains the new sprites. A series of real sprites has to be specified between the curly braces ({ and }). The first sprite in this list replaces the sprite with id sprite-id, the second replaces sprite-id + 1 and so on. Sprite templates can be used as well. For example:

 // Rail overlays for crossings
 replace rail_overlays(1005, "src/gfx/rails_overlays.png") {
 		[ 20,198, 40,21, -20,  5]
 		[ 71,198, 40,21, -20,  5]
 		[117,198, 40, 7, -20,  5]
 		[165,198, 40, 7, -20, 21]
 		[216,198, 12,19,  10,  5]
 		[248,198, 12,19, -24, 11]
 }