The code for road and tram types consists of three parts:
The definition sets the feature properties of the road/tram type like its label, related texts, speedlimit, etc. Please note that a road/tram type definition may only occur after a prior grfinit() function call for the newGRF file.
The road/tram type's performance functions are used to group sets of graphics sprites from a previous spriteblock(), or to evaluate game-intrinsic variables, and make both of them accessible to the road/tram type's activation function.
The road/tram type activation instantiates the road/tram type by finally assigning graphics sets to a particular road/tram type element (icon, road/tram underlay, tunnel, catenary, ...). This is done by supplying a block of special functions handling references and road/tram type elements to the road/tram type's activation. See below.
| Function | Meaning |
| defineroadtype/definetramtype(<Label>, <block>) | Road/tram type definition |
| makeroadtype/maketramtype(<Label>, <block>) | Road/tram type activation |
defineroadtype/definetramtype(<Label>, <block>)
This function defines a road/tram type. Its parameters are the road/tram type's label and a block of property-defining functions, where the relative position of the property functions is irrelevant.
Please note that the label has to be quoted like this: {HWAY}.
Road/tram type IDs are newGRF local, with an ID to label mapping. Therefore, to modify an existing road/tram type, specify its label in defineroadtype/definetramtype(). To create a new road/tram type, again just specify its label in defineroadtype/definetramtype(). If a label clashes with another newGRF, then one newGRF will end up modifying the properties instead of creating a new road/tram type. At the time being, there are 63 road/track IDs available (0 .. 62).
Reserved labels for default road/tram types are: ROAD (default road), ELRD (electrified road), RAIL (default tram), ELRL (electrified tram).
deftxt(rt_tool,
US, "Motorway construction",
UK, "Motorway construction",
D, "Autobahnbau",
F, UTF8 "Construction autoroutière",
E, UTF8 "ConstruccĂon de carreteras",
)
...
defineroadtype({HWAY},
toolbartext(rt_tool)
menutext(rt_menu)
vehwindowtext(rt_window)
autoreplacetext(rt_autoreplace)
newenginetext(rt_engine)
powered_list({"ROAD"})
roadtypeflags(RT_HOUS)
costfactor(100)
speedlimit(130 km/h)
mapcolour(170)
)
makeroadtype/maketramtype(<Label>, <block>)
This function activates a previously defined road/tram type. Its parameters are the road/tram type's label and a block of special road/tram type feature-associated functions:
| Function | Meaning |
| Linking a chain of graphics or variable dependencies to a specific road/tram type element | |
| default(<ref()>) | Default chain to use with this road/tram type |
Road/tram type elements assign certain types of graphics defined by their associated chains:
| Road/tram type element | Sprite type | Num sprites | Usage |
| RT_ICON | Icons and cursors[*] | 12 | 4 road/tram directions, autoroad, depot, convert road/tram. First all icons, then all cursors |
| RT_OLAY | Road/tram track overlays [*] | 19 | 11 combinations, 4 slope pieces, and 4 dead ends. Sprites should contain only the the road/tram track, with no landscape |
| RT_ULAY | Underlay[*] | 19 | same as RT_OLAY |
| RT_WIRE | Catenary wire | 29 | 11 track combinations, 4 slopes, 4 dead ends, 4 tunnels, 2 middle bridge, and 4 bridge ramps |
| RT_PYLN | Catenary pylons | 29 | same as above, only tunnels unused |
| RT_BRDG | Bridge surfaces[*] | 6 | 2 middle bridge, and 4 bridge ramps |
| RT_DEPO | Depots | 6 | 2 sprites for each southern view, 1 sprite for each northern view, following the original layout for depot sprites |
| RT_STOP | Road stop | 4 | overlays for drive-in road stops |
[*] These sprites must be provided, the others may be left out if not needed.
| Sprite number | Usage |
| 0 | NE wall for SE-entry depot |
| 1 | Depot building for SE-entry |
| 2 | NW wall for SW-entry depot |
| 3 | Depot building for SW-entry |
| 4 | Depot building for NE-entry |
| 5 | Depot building for NW-entry |
makeroadtype(HWAY, link(ref(7), RT_ICON) // icons and cursors link(ref(11), RT_OLAY) // track overlays for junctions and PBS link(ref(2), RT_ULAY) // track underlays link(ref(4), RT_BRDG) // bridge surfaces link(ref(8), RT_DEPO) // depot sprites link(ref(10), RT_PYLN) // catenary pylons link(ref(9), RT_WIRE) // catenary wires default(cbfail()) // s.b. )