Difference between revisions of "NML:Replace new sprites"

From GRFSpecs
Jump to navigationJump to search
m (OTTD_GUI now supports up to 162 sprites)
(new unified SIGNALS type)
 
(21 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
{{NMLNavBlocksyntax}}
 
{{NMLNavBlocksyntax}}
   
Over time, several features have been added to TTDPatch and OpenTTD that require new sprites. As these sprites are not present in the original base graphics, they cannot be replaced using a normal <code style="color:darkgreen">replace</code> block. Instead, a <code style="color:darkgreen">replacenew</code> block has to be used. The semantics are like this:
+
Over time, several features have been added to OpenTTD that require new sprites. As these sprites are not present in the original base graphics and only found in the extra grf of each base set. They cannot be replaced using a normal <code style="color:darkgreen">replace</code> block. Instead, a <code style="color:darkgreen">replacenew</code> block has to be used. The semantics are like this:
   
replacenew(&lt;type&gt;, &lt;image-file&gt;[, &lt;offset&gt;]) {
+
replacenew [&lt;block-name&gt;](&lt;type&gt;, [&lt;image-file&gt;[, &lt;offset&gt;]]) {
 
[[NML:Realsprites|list of realsprites]]
 
[[NML:Realsprites|list of realsprites]]
 
}
 
}
  +
  +
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 <code style="color:darkgreen">&lt;type&gt;</code> parameter indicates the type of sprites that will be replaced. It should be an identifier from the first column of the following table.
 
The <code style="color:darkgreen">&lt;type&gt;</code> parameter indicates the type of sprites that will be replaced. It should be an identifier from the first column of the following table.
   
  +
For information on what sprites are needed and in what order, it's generally best to look at the OpenGFX source [https://github.com/OpenTTD/OpenGFX/tree/master/sprites/extra], in the sprites/extra directory.
{| class="t"
 
  +
  +
{| class="wikitable sortable"
  +
 
! Type
 
! Type
 
! Number of sprites
 
! Number of sprites
 
|-
 
|-
  +
| SIGNALS <ref>In older versions this was named PRE_SIGNAL, PRE_SIGNAL_SEMAPHORE and PRE_SIGNAL_SEMAPHORE_PBS.</ref>
| PRE_SIGNAL
 
| 48
 
|-
 
| PRE_SIGNAL_SEMAPHORE
 
| 112
 
|-
 
| PRE_SIGNAL_SEMAPHORE_PBS
 
 
| 240
 
| 240
 
|-
 
|-
Line 30: Line 29:
 
| FOUNDATIONS_SLOPES_HALFTILES
 
| FOUNDATIONS_SLOPES_HALFTILES
 
| 90
 
| 90
|-
+
|-
  +
<!-- This is not usable anyway, as NML 0.3 is grf v8
 
| TTDP_GUI_25
 
| TTDP_GUI_25
  +
| 73<ref name="no_offset" />
| 73
 
 
|-
 
|-
 
| TTDP_GUI
 
| TTDP_GUI
  +
| 93<ref name="no_offset" />
| 93
 
|-
+
|-
  +
-->
 
| CANALS
 
| CANALS
 
| 65
 
| 65
Line 47: Line 48:
 
|-
 
|-
 
| TRAMWAY
 
| TRAMWAY
  +
| 113 {{ottdp|1.10|no}} {{nml|0.5}} 119
| 113
 
 
|-
 
|-
  +
<!--
 
| SNOWY_TEMPERATE_TREES
 
| SNOWY_TEMPERATE_TREES
  +
| 133<ref name="no_offset" />
| 133
 
 
|-
 
|-
  +
-->
 
| COAST_TILES
 
| COAST_TILES
  +
| 16<ref name="no_offset">This type does not support the use of an offset. Thus the exact amount of sprites must be supplied.</ref>
| 16
 
 
|-
 
|-
 
| COAST_TILES_BASEGFX
 
| COAST_TILES_BASEGFX
  +
| 10<ref name="no_offset" />
| 10
 
 
|-
 
|-
 
| COAST_TILES_DIAGONAL
 
| COAST_TILES_DIAGONAL
  +
| 18<ref name="no_offset" />
| 18
 
 
|-
 
|-
  +
<!--
 
| NEW_SIGNALS
 
| NEW_SIGNALS
 
| any <ref name="not_supported">Any number of sprites is allowed here, however both OpenTTD and NML don't (yet) support the other features required to use these sprites.</ref>
| any (a)
 
 
|-
 
|-
  +
-->
 
| SLOPED_RAILS
 
| SLOPED_RAILS
 
| 12
 
| 12
Line 80: Line 85:
 
|-
 
|-
 
| FLAGS
 
| FLAGS
| 36 (b)
+
| 36
 
|-
 
|-
 
| OTTD_GUI
 
| OTTD_GUI
| 162 (b)
+
| 191
 
|-
 
|-
 
| AIRPORT_PREVIEW
 
| AIRPORT_PREVIEW
| 9 (b)
+
| 9
 
|-
  +
| RAILTYPE_TUNNELS
 
| 16
 
|-
  +
| OTTD_RECOLOUR
 
| 1
 
|}
 
|}
   
 
Parameter two <code style="color:darkgreen">&lt;image-file&gt;</code> (optional) is a literal (quoted) string that specifies the default file where the sprites are located. This may be overridden per-sprite.
(a) Any number of sprites is allowed here, however both OpenTTD and NML don't (yet) support the other features required to use these sprites.
 
 
(b) Any number of sprites can be specified up to the stated maximum. Furthermore the <code style="color:darkgreen">offset</code> variable can be used, see below for more info.
 
 
The amount of sprites has to be equal to the number given in the table, except in the cases of (a) and (b). Having less sprites results in an error. Having more sprites is allowed to provide future compatibility, but a warning will be issued.
 
   
 
Parameter <code style="color:darkgreen">&lt;offset&gt;</code> is optional and has a default value of 0. Setting this value sets an offset into the block of sprites, so only a subset of the sprites (starting at <code style="color:darkgreen">offset</code>) will be replaced. An offset is not allowed in the case of the sprite types marked with <ref name="no_offset" />. Don't use offsets, if you want you NewGRF compatible with TTDPatch.
Parameter two <code style="color:darkgreen">&lt;image-file&gt;</code> is a literal (quoted) string that specifies the file where the sprites are located.
 
   
  +
<references />
Parameter <code style="color:darkgreen">&lt;offset&gt;</code> is optional and has a default value of 0. Values greater than zero are only allowed in the case of the sprite types marked with (b). Setting this value sets an offset into the block of sprites, so only a subset of the sprites (starting at <code style="color:darkgreen">offset</code>) will be replaced.
 

Latest revision as of 21:18, 27 June 2023

Block Syntax

Over time, several features have been added to OpenTTD that require new sprites. As these sprites are not present in the original base graphics and only found in the extra grf of each base set. They cannot be replaced using a normal replace block. Instead, a replacenew block has to be used. The semantics are like this:

replacenew [<block-name>](<type>, [<image-file>[, <offset>]]) {
	list of realsprites
}

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 <type> parameter indicates the type of sprites that will be replaced. It should be an identifier from the first column of the following table.

For information on what sprites are needed and in what order, it's generally best to look at the OpenGFX source [1], in the sprites/extra directory.

Type Number of sprites
SIGNALS [1] 240
CATENARY 48
FOUNDATIONS_SLOPES 74
FOUNDATIONS_SLOPES_HALFTILES 90
CANALS 65
ONE_WAY_ROAD 6
COLOURMAP_2CC 256
TRAMWAY 113 Supported by OpenTTD 1.101.10 Not supported by TTDPatch NML 0.5 119
COAST_TILES 16[2]
COAST_TILES_BASEGFX 10[2]
COAST_TILES_DIAGONAL 18[2]
SLOPED_RAILS 12
AIRPORTS 15
ROAD_STOPS 8
AQUEDUCTS 8
AUTORAIL 55
FLAGS 36
OTTD_GUI 191
AIRPORT_PREVIEW 9
RAILTYPE_TUNNELS 16
OTTD_RECOLOUR 1

Parameter two <image-file> (optional) is a literal (quoted) string that specifies the default file where the sprites are located. This may be overridden per-sprite.

Parameter <offset> is optional and has a default value of 0. Setting this value sets an offset into the block of sprites, so only a subset of the sprites (starting at offset) will be replaced. An offset is not allowed in the case of the sprite types marked with [2]. Don't use offsets, if you want you NewGRF compatible with TTDPatch.

  1. In older versions this was named PRE_SIGNAL, PRE_SIGNAL_SEMAPHORE and PRE_SIGNAL_SEMAPHORE_PBS.
  2. 2.0 2.1 2.2 2.3 This type does not support the use of an offset. Thus the exact amount of sprites must be supplied.