The code for stations consists of three parts:
The station's definition sets the feature properties of the station like size, layout, etc. Please note that a station definition may only occur after a prior grfinit() function call for the newGRF file.
The station'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 station's activation function.
The station's activation instantiates the station by finally assigning graphics sets and/or callbacks or other variable-referencing functions to this particular station. This is done by supplying a block of special functions handling references and cargo types to the station's activation. See below.
Function | Meaning |
classnames(<Station-ID>, {<Language-ID>, {<String>}}) | Definition of station class name(s) |
definestation(<Station-ID>, {<String>}, <block>) | Station definition |
makestation(<Station-ID>, <block>) | Station activation |
stationnames(<Station-ID>, {<Language-ID>, {<String>}}) | Definition of station name(s) |
classnames(<Station-ID>, {<Language-ID>, {<String>}})
This function defines the name(s) of the station class(es), associated with one or more station-IDs. It is used in the same way as stationnames(). Both functions have to be used after the appropriate <Station-ID> has been defined by function definestation().
It is possible to define either one language and multiple strings for multiple (consecutive) IDs, or one ID to be associated with one string from multiple languages, or both.
Please note that entries must be quoted, see examples.
classnames(_ROOFS, {UK,"Platforms"}, {D,"Bahnsteige"}, {F,"Quais"}, {E,UTF8 "Andénes"}, {I,"Banchine"} )Example 2 (multiple strings in one language for multiple IDs):
classnames(_ROOFS, {UK,"Platforms", "Roofs", "Underpasses"} )Example 3 (multiple strings in multiple languages for multiple IDs):
classnames(_ROOFS, {UK,"Platforms", "Roofs", "Underpasses"}, {D,"Bahnsteige", UTF8 "Dächer", UTF8 "Überwegungen"} )
As shown here, you might template the input to classnames(), as well as input to stationnames(), see below.
Please note that both class names and station names should be defined after the station's definition.
definestation(<Station-ID>, {<String>}, <block>)
This function defines one or more station(s). Its parameters are the (first) station's ID, one or more text string(s) giving the default name(s) of the station, and a block of property-defining functions, where the relative position of the property functions is irrelevant.
When specifying more than one station ID, please note that the same number of names have to be supplied by the second parameter, in the same fashion like it is done in function classnames() and stationnames(). IDs for multiple stations will be specified in a consecutive manner, i.e. with WAYP0 set to 0, additional stations in the second example will get IDs 1 .. 3.
definestation(_ROOFS,"Roofs", class(PLATFORMS) callbacks(CB_LAYOUT) exclude_widths(8) exclude_lengths(8) threshold(36) nopylons(0) flags({GROUNDSPRITES, DIVAMOUNT, FOUNDATIONS}) )Example 2 (definition of 4 way points in one go):
definestation(WAYP0,{"regular", "regular", "regular", "gantry"}, class("WAYP","WAYP","WAYP","WAYP") callbacks(CB_LAYOUT,CB_LAYOUT,CB_LAYOUT,CB_LAYOUT) include_widths({1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4}) include_lengths(1,1,1,1) flags(GROUNDSPRITES,GROUNDSPRITES,GROUNDSPRITES,GROUNDSPRITES) )
makestation(<Station-ID>, <block<)
This function activates a previously defined station. Its parameters are the station's ID and a block of special cargo-associated functions:
Function | Meaning |
Linking a chain of graphics or variable-dependencies to this station | |
default(<ref()>) | Default chain to use with this station |
For special purposes, the station-ID may be omitted to create a "generic callback" (CB_AISELECT).
This function links a reference to a chain of functions describing graphics and/or variable evaluations with a particular cargo type. Its parameters are the reference to the function chain and a cargo type.
For stations, you can additionally define a SPECIAL cargo type which prevents the default from being used (which would show the sum of all cargo). Instead, the given set-ID is displayed with no cargo at all.
This function is used if no entry from the link() function(s) matches, or if there are no special cargo-types listed at all in a link() function.
makestation(_ROOFS, link(ref(21), MENU) link(ref(20), PASS, SPECIAL) default(ref(20)) )
stationnames(<Station-ID>, {<Language-ID>, {<String>}})
This function defines more names for one or more station(s) than the default one given by definestation(). It should be used if a station needs names in more than one language. Its parameters are the (first) station's ID and a block consisting of language IDs and associated names.
Usage is exactly like classnames(). See examples above.