Difference between revisions of "NML:Stations"

From GRFSpecs
Jump to navigationJump to search
(→‎Station variables: Add 60+X variables)
(→‎Station variables: Some additions / corrections)
Line 63: Line 63:
 
| cargo_last_vehicle_speed
 
| cargo_last_vehicle_speed
 
| 0..255
 
| 0..255
| Speed of the last vehicle picking up this cargo type. The unit depends on the type of vehicle. For trains and road vehicles, one unit is 1 km/h; for ships, it's 0.5 km/h; for aircraft, it's 8 mph. If the max. speed is above 255 speed units, 255 is used instead
+
| Speed of the last vehicle picking up this cargo type. The unit depends on the type of vehicle. For trains and road vehicles, one unit is 1 km/h; for ships, it's 0.5 km/h; for aircraft, it's 8 mph. If the max. speed is above 255 speed units, 255 is used instead. 0 if no vehicle as picked up the cargo type yet.
 
|-
 
|-
 
| cargo_last_vehicle_age
 
| cargo_last_vehicle_age
 
| 0..255
 
| 0..255
| Age of the last vehicle picking up this cargo type, in years.
+
| Age of the last vehicle picking up this cargo type, in years. 255 if no vehicle has picked up the cargo type yet.
 
|-
 
|-
 
| cargo_accepted
 
| cargo_accepted
Line 198: Line 198:
 
|-
 
|-
 
| nearby_tile_slope
 
| nearby_tile_slope
  +
| tile- and platform-offset <ref name="offset">The first parameter is the distance to move along the platform, the second parameter is the distance to move sideways (between platforms). Both parameters are signed numbers with range -8..7, negative numbers go northwards.</ref>
| x- and y-offset (both signed, range -8..7)
 
 
| SLOPE_XXX
 
| SLOPE_XXX
| See [[NML:List of tile slopes|tile slopes]] for an overview of possible values
+
| See [[NML:List of tile slopes|tile slopes]] for an overview of possible values. Note that the slope is 'mirrored' in the NW-SE orientation, i.e. the bits for CORNER_W and CORNER_E are swapped.
 
|-
 
|-
 
| nearby_tile_is_water
 
| nearby_tile_is_water
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| [0 <nowiki>|</nowiki> 1]
 
| [0 <nowiki>|</nowiki> 1]
 
| 1 if the tile is water, 0 otherwise
 
| 1 if the tile is water, 0 otherwise
 
|-
 
|-
 
| nearby_tile_terrain_type
 
| nearby_tile_terrain_type
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| TILETYPE_XX
 
| TILETYPE_XX
 
| TILETYPE_NORMAL, TILETYPE_DESERT, TILETYPE_RAIN_FOREST, TILETYPE_SNOW
 
| TILETYPE_NORMAL, TILETYPE_DESERT, TILETYPE_RAIN_FOREST, TILETYPE_SNOW
 
|-
 
|-
 
| nearby_tile_water_class
 
| nearby_tile_water_class
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| WATER_CLASS_XXX
 
| WATER_CLASS_XXX
 
| XXX = [NONE <nowiki>|</nowiki> SEA <nowiki>|</nowiki> CANAL <nowiki>|</nowiki> RIVER] Note that tiles for which <code style="color:darkgreen">nearby_tile_is_water</code> is 0 may still have a water class, e.g. industry tiles with water beneath them.
 
| XXX = [NONE <nowiki>|</nowiki> SEA <nowiki>|</nowiki> CANAL <nowiki>|</nowiki> RIVER] Note that tiles for which <code style="color:darkgreen">nearby_tile_is_water</code> is 0 may still have a water class, e.g. industry tiles with water beneath them.
 
|-
 
|-
 
| nearby_tile_height
 
| nearby_tile_height
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| 0..255 (currently limited to 0..15)
 
| 0..255 (currently limited to 0..15)
 
| Height of the lowest corner of the tile. 1 unit is one height level of 8 pixels.
 
| Height of the lowest corner of the tile. 1 unit is one height level of 8 pixels.
 
|-
 
|-
 
| nearby_tile_class
 
| nearby_tile_class
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
|
 
|
 
[[NML:List of tile classes|Tile class]]
 
[[NML:List of tile classes|Tile class]]
Line 229: Line 229:
 
|-
 
|-
 
| nearby_tile_animation_frame
 
| nearby_tile_animation_frame
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| 0..255
 
| 0..255
 
| Animation frame of the given tile
 
| Animation frame of the given tile
 
|-
 
|-
 
| nearby_tile_is_station
 
| nearby_tile_is_station
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| [0 <nowiki>|</nowiki> 1]
 
| [0 <nowiki>|</nowiki> 1]
 
| 1 if the given tile is a station tile, 0 otherwise
 
| 1 if the given tile is a station tile, 0 otherwise
 
|-
 
|-
 
| nearby_tile_station_id
 
| nearby_tile_station_id
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| 0..255
 
| 0..255
 
| If the given tile is a station tile defined by this NewGRF, the item ID. Else, the content is undefined.
 
| If the given tile is a station tile defined by this NewGRF, the item ID. Else, the content is undefined.
 
|-
 
|-
 
| nearby_tile_same_grf
 
| nearby_tile_same_grf
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| [0 <nowiki>|</nowiki> 1]
 
| [0 <nowiki>|</nowiki> 1]
 
| 1 if the given tile is a station tile defined by this NewGRF, 0 otherwise.
 
| 1 if the given tile is a station tile defined by this NewGRF, 0 otherwise.
 
|-
 
|-
 
| nearby_tile_other_grf
 
| nearby_tile_other_grf
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| [0 <nowiki>|</nowiki> 1]
 
| [0 <nowiki>|</nowiki> 1]
 
| 1 if the given tile is a station tile defined by a different NewGRF, 0 otherwise.
 
| 1 if the given tile is a station tile defined by a different NewGRF, 0 otherwise.
 
|-
 
|-
 
| nearby_tile_original_gfx
 
| nearby_tile_original_gfx
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| [0 <nowiki>|</nowiki> 1]
 
| [0 <nowiki>|</nowiki> 1]
 
| 1 if the given tile is a station tile with original graphics, 0 otherwise.
 
| 1 if the given tile is a station tile with original graphics, 0 otherwise.
 
|-
 
|-
 
| nearby_tile_same_station
 
| nearby_tile_same_station
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| [0 <nowiki>|</nowiki> 1]
 
| [0 <nowiki>|</nowiki> 1]
 
| 1 if the given tile is part of the same station, 0 otherwise. Undefined if the tile is not a station tile.
 
| 1 if the given tile is part of the same station, 0 otherwise. Undefined if the tile is not a station tile.
 
|-
 
|-
 
| nearby_tile_perpendicular
 
| nearby_tile_perpendicular
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| [0 <nowiki>|</nowiki> 1]
 
| [0 <nowiki>|</nowiki> 1]
 
| 1 if the given tile a station tile aligned perpendicular to this tile, 0 if it is aligned parallel. Undefined if the tile is not a station tile.
 
| 1 if the given tile a station tile aligned perpendicular to this tile, 0 if it is aligned parallel. Undefined if the tile is not a station tile.
 
|-
 
|-
 
| nearby_tile_platform_type
 
| nearby_tile_platform_type
| x- and y-offset (both signed, range -8..7)
+
| tile- and platform-offset <ref name="offset"/>
 
| 0..3
 
| 0..3
 
| Platform type of the given tile. Value is undefined if the tile is not a station tile, else possible values are:
 
| Platform type of the given tile. Value is undefined if the tile is not a station tile, else possible values are:

Revision as of 15:05, 18 September 2012

Props, Vars and CBs

Stations in NML are currently a work-in-progress. Therefore, things may be added, changed or removed without notice. At the moment, it is not yet possible to write your own station NewGRF in NML.

Station properties

There are no properties defined yet

Station variables

Base station variables

The following variables are shared between stations and airports:

name value range comment
had_vehicle_of_type bitmask(HAD_VEHICLE_OF_TYPE_XXX, ...) Bitmask of vehicle types that have visited the station. XXX = [TRAIN | BUS | TRUCK | AIRCRAFT | SHIP].
is_waypoint [0 | 1] Whether the station is a waypoint
facilities bitmask(FACILITY_XXX, ...) Bitmask of facilities associated with the station. XXX = [TRAIN | TRUCK_STOP | BUS_STOP | AIRPORT | DOCK].
airport_type AIRPORTTYPE_XXX Type of airport, contains a bogus value if the station has no airport. XXX = [SMALL | LARGE | HELIPORT | OILRIG].
build_date date(yyyy,mm,dd) Date when the station was built. Is clamped to the 1920-2099 range.


The following variables are also shared with airports. They all require a single argument: a cargo type from your cargo translation table.

name value range comment
cargo_amount_waiting 0..32767 Units of cargo of waiting
cargo_rating 0..100 Rating for this cargo type (in %)
cargo_time_since_pickup 0..255 Time since the cargo was last picked up. 1 unit equals 185 ticks, or about 2.5 game days.
cargo_time_en_route 0..255 Time this cargo has spent en-route. 1 unit equals 185 ticks, or about 2.5 game days.
cargo_last_vehicle_speed 0..255 Speed of the last vehicle picking up this cargo type. The unit depends on the type of vehicle. For trains and road vehicles, one unit is 1 km/h; for ships, it's 0.5 km/h; for aircraft, it's 8 mph. If the max. speed is above 255 speed units, 255 is used instead. 0 if no vehicle as picked up the cargo type yet.
cargo_last_vehicle_age 0..255 Age of the last vehicle picking up this cargo type, in years. 255 if no vehicle has picked up the cargo type yet.
cargo_accepted [0 | 1] 1 if this cargo type is currently being accepted at the station, 0 otherwise.
cargo_accepted_ever [0 | 1] 1 if this cargo type has ever been accepted at the station, 0 otherwise.
cargo_accepted_last_month [0 | 1] 1 if this cargo type was accepted last month at the station, 0 otherwise.
cargo_accepted_this_month [0 | 1] 1 if this cargo type was accepted this month at the station, 0 otherwise.
cargo_accepted_bigtick [0 | 1] 1 if this cargo type was accepted at the station since the last periodic processing, which happens every 250 ticks. 0 otherwise.


Variables without a parameter

name value range comment
tile_type 0..7 The type of tile, as defined in your station layout
terrain_type TILETYPE_XX TILETYPE_NORMAL, TILETYPE_DESERT, TILETYPE_RAIN_FOREST, TILETYPE_SNOW
track_type Entry from railtype translation table
company_num 0 ... 14 company number of the vehicle owner. TTDPatch only supports up to 8 companies (0 ... 7)
company_type PLAYERTYPE_XX
PLAYERTYPE_HUMAN
human player
PLAYERTYPE_AI
AI player
PLAYERTYPE_HUMAN_IN_AI
human managing AI company
PLAYERTYPE_AI_IN_HUMAN
AI managing human company

OpenTTD only uses PLAYERTYPE_HUMAN and PLAYERTYPE_AI. If you cheat yourself to be part of an AI company OpenTTD will still report PLAYERTYPE_AI for the company with yourself and the AI and it'll report PLAYERTYPE_HUMAN for the now uncontrolled company.

company_colour1 COLOUR_XXX

Refer to the table here for possible values.

company_colour2 COLOUR_XXX

Same as company_colour1, if no 2nd company colour is chosen. Refer to the table here for possible values.

pbs_reserved [0 | 1] 1 if the tile has been reserved by a train for PBS (Path-based signalling) purposes, 0 otherwise.
pbs_reserved_or_disabled [0 | 1] 1 if the tile has been reserved by a train for PBS (Path-based signalling) purposes, or if PBS is not enabled. Currently PBS is always considered enabled if the game version used supports it, but in the future, this may change to check if the current signal block actually uses PBS-signals.
pbs_enabled [0 | 1] 1 if PBS is enabled. Currently PBS is always considered enabled if the game version used supports it, but in the future, this may change to check if the current signal block actually uses PBS-signals.
rail_continuation bitmask(0, ... 7) see below
rail_present bitmask(0, ... 7) see below
animation_frame 0..255 Animation frame of the current tile.

Rail continuation

Variables rail_continuation and rail_present both contain a bitmask, with 8 possible bits set. Each bit corresponds to one of the adjacent tiles, refer to the table or picture below. The bit in rail_present is set if the tile contains any rail track. Bits 0..3 in rail_continuation are only set if there is rail track on the tile and if that track connects to the current tile (note that this tile has no connection to the tiles corresponding to bits 2 and 3, but that doesn't matter). Bits 4..7 in rail_continuation are set if there is track on the tile and if that track connects to tile 2 or 3, whichever is applicable.

Bit Set if rail continues in direction of...
0 +Length
1 -Length
2 +Platforms
3 -Platforms
4 +Length, +Platforms
5 -Length, +Platforms
6 +Length, -Platforms
7 -Length, -Platforms

The following picture illustrates which bits represent which tile for the two possible station orientations:

Station var45.png

Variables that require one or more arguments

name arguments value range comment
nearby_tile_slope tile- and platform-offset [1] SLOPE_XXX See tile slopes for an overview of possible values. Note that the slope is 'mirrored' in the NW-SE orientation, i.e. the bits for CORNER_W and CORNER_E are swapped.
nearby_tile_is_water tile- and platform-offset [1] [0 | 1] 1 if the tile is water, 0 otherwise
nearby_tile_terrain_type tile- and platform-offset [1] TILETYPE_XX TILETYPE_NORMAL, TILETYPE_DESERT, TILETYPE_RAIN_FOREST, TILETYPE_SNOW
nearby_tile_water_class tile- and platform-offset [1] WATER_CLASS_XXX XXX = [NONE | SEA | CANAL | RIVER] Note that tiles for which nearby_tile_is_water is 0 may still have a water class, e.g. industry tiles with water beneath them.
nearby_tile_height tile- and platform-offset [1] 0..255 (currently limited to 0..15) Height of the lowest corner of the tile. 1 unit is one height level of 8 pixels.
nearby_tile_class tile- and platform-offset [1]

Tile class

nearby_tile_animation_frame tile- and platform-offset [1] 0..255 Animation frame of the given tile
nearby_tile_is_station tile- and platform-offset [1] [0 | 1] 1 if the given tile is a station tile, 0 otherwise
nearby_tile_station_id tile- and platform-offset [1] 0..255 If the given tile is a station tile defined by this NewGRF, the item ID. Else, the content is undefined.
nearby_tile_same_grf tile- and platform-offset [1] [0 | 1] 1 if the given tile is a station tile defined by this NewGRF, 0 otherwise.
nearby_tile_other_grf tile- and platform-offset [1] [0 | 1] 1 if the given tile is a station tile defined by a different NewGRF, 0 otherwise.
nearby_tile_original_gfx tile- and platform-offset [1] [0 | 1] 1 if the given tile is a station tile with original graphics, 0 otherwise.
nearby_tile_same_station tile- and platform-offset [1] [0 | 1] 1 if the given tile is part of the same station, 0 otherwise. Undefined if the tile is not a station tile.
nearby_tile_perpendicular tile- and platform-offset [1] [0 | 1] 1 if the given tile a station tile aligned perpendicular to this tile, 0 if it is aligned parallel. Undefined if the tile is not a station tile.
nearby_tile_platform_type tile- and platform-offset [1] 0..3 Platform type of the given tile. Value is undefined if the tile is not a station tile, else possible values are:
0
plain platform
1
platform with building
2
platform with roof, left side
3
platform with roof, right side
platform_length PLATFROM_SAME_XXX[2] 0..15 Length of the platform (along the platform direction) in tiles
platform_count PLATFORM_SAME_XXX[2] 0..15 Number of platforms (counted perpendicular to the platform direction)
platform_position_from_start PLATFORM_SAME_XXX[2] 0..15 Position along the platform, 0 for the first (northernmost) tile.
platform_position_from_end PLATFORM_SAME_XXX[2] 0..15 Position along the platform, 0 for the last (southernmost) tile.
platform_position_from_middle PLATFORM_SAME_XXX[2] -8..7 Position along the platform, 0 for the middle tile. When the number of tiles is even, the southernmost of the two middle tiles is assigned number 0, so there is one more negative than positive number. Using PLATFORM_SAME_DIRECTION is not possible here.
platform_number_from_start PLATFORM_SAME_XXX[2] 0..15 Platform number, counting from top to bottom, so 0 for the northernmost platform.
platform_number_from_end PLATFORM_SAME_XXX[2] 0..15 Platform number, counting from bottom to top, so 0 for the southernmost platform.
platform_number_from_middle PLATFORM_SAME_XXX[2] -8..7 Platform number, counting top to bottom, using 0 for the middle platform. When the number of platforms is even, the southernmost of the two middle platformsis assigned number 0, so there is one more negative than positive number. Using PLATFORM_SAME_DIRECTION is not possible here.
  1. 1.00 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 1.12 1.13 1.14 The first parameter is the distance to move along the platform, the second parameter is the distance to move sideways (between platforms). Both parameters are signed numbers with range -8..7, negative numbers go northwards.
  2. 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 Possible values are:
    PLATFORM_SAME_STATION
    Consider all tiles that are part of the same station
    PLATFORM_SAME_SECTION
    Consider all tiles that are part of the same individually built section
    PLATFORM_SAME_DIRECTION
    Consdier all tiles that are part of the same station and have the same platform direction.

Station callbacks

There are no callbacks defined yet