Difference between revisions of "NML:General"
From GRFSpecs
Jump to navigationJump to search (some content not displayed due to wiki not liking | in normal text. Also added a lot of <code>, but unsure if I like it better that way. Let's use this as a demo to see what others think.) |
Planetmaker (talk | contribs) (indicate use of some switches and use references where applicable) |
||
Line 82: | Line 82: | ||
|- |
|- |
||
| <code style="color:green">climate</code> |
| <code style="color:green">climate</code> |
||
⚫ | |||
− | | Yes (a) |
||
| <code style="color:green">CLIMATE_XXX</code> with <code style="color:green">XXX</code> = [<code style="color:green">TEMPERATE</code> <nowiki>|</nowiki> <code style="color:green">ARCTIC</code> <nowiki>|</nowiki> <code style="color:green">TROPICAL</code> <nowiki>|</nowiki> <code style="color:green">TOYLAND</code>] |
| <code style="color:green">CLIMATE_XXX</code> with <code style="color:green">XXX</code> = [<code style="color:green">TEMPERATE</code> <nowiki>|</nowiki> <code style="color:green">ARCTIC</code> <nowiki>|</nowiki> <code style="color:green">TROPICAL</code> <nowiki>|</nowiki> <code style="color:green">TOYLAND</code>] |
||
| |
| |
||
Line 97: | Line 97: | ||
|- |
|- |
||
| <code style="color:green">difficulty_level</code> |
| <code style="color:green">difficulty_level</code> |
||
− | | Yes |
+ | | Yes <ref name=gamechange /> |
| <code style="color:green">DIFFICULTY_XXX</code> with <code style="color:green">XXX</code> = [<code style="color:green">EASY</code> <nowiki>|</nowiki> <code style="color:green">MEDIUM</code> <nowiki>|</nowiki> <code style="color:green">HARD</code> <nowiki>|</nowiki> <code style="color:green">CUSTOM</code>] |
| <code style="color:green">DIFFICULTY_XXX</code> with <code style="color:green">XXX</code> = [<code style="color:green">EASY</code> <nowiki>|</nowiki> <code style="color:green">MEDIUM</code> <nowiki>|</nowiki> <code style="color:green">HARD</code> <nowiki>|</nowiki> <code style="color:green">CUSTOM</code>] |
||
| |
| |
||
Line 107: | Line 107: | ||
|- |
|- |
||
| <code style="color:green">desert_paved_roads</code> |
| <code style="color:green">desert_paved_roads</code> |
||
⚫ | |||
− | | Yes (b) |
||
+ | |||
⚫ | |||
⚫ | |||
⚫ | |||
| 0 or 1 |
| 0 or 1 |
||
| If 1, desert roads have pavement and street lights. |
| If 1, desert roads have pavement and street lights. |
||
|- |
|- |
||
| <code style="color:green">train_width_32_px</code> |
| <code style="color:green">train_width_32_px</code> |
||
− | | Yes |
+ | | Yes <ref name=readwrite /> |
| 0 or 1 |
| 0 or 1 |
||
| If 1, train vehicles are 32 instead of 29 pixels wide in the depot view. |
| If 1, train vehicles are 32 instead of 29 pixels wide in the depot view. |
||
|- |
|- |
||
| <code style="color:green">traininfo_y_offset</code> |
| <code style="color:green">traininfo_y_offset</code> |
||
− | | Yes |
+ | | Yes <ref name=readwrite /> |
| -128 .. 127 |
| -128 .. 127 |
||
| Used to correctly position the depot view of trains. |
| Used to correctly position the depot view of trains. |
||
Line 127: | Line 131: | ||
|- |
|- |
||
| <code style="color:green">traffic_side</code> |
| <code style="color:green">traffic_side</code> |
||
− | | Yes |
+ | | Yes <ref name=gamechange /> |
| <code style="color:green">TRAFFIC_SIDE_LEFT</code> or <code style="color:green">TRAFFIC_SIDE_RIGHT</code> |
| <code style="color:green">TRAFFIC_SIDE_LEFT</code> or <code style="color:green">TRAFFIC_SIDE_RIGHT</code> |
||
| |
| |
||
Line 213: | Line 217: | ||
| <code style="color:green">bridge_speed_limits</code> |
| <code style="color:green">bridge_speed_limits</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 1 |
| |
| |
||
|- |
|- |
||
Line 228: | Line 232: | ||
| <code style="color:green">unified_maglev</code> |
| <code style="color:green">unified_maglev</code> |
||
| Yes |
| Yes |
||
− | | 0 .. 3 |
+ | | {{ttdp|}} 0 .. 3 {{ottd|}} Always 3 |
| |
| |
||
|- |
|- |
||
| <code style="color:green">temperate_snowline</code> |
| <code style="color:green">temperate_snowline</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 0 |
| |
| |
||
|- |
|- |
||
Line 243: | Line 247: | ||
| <code style="color:green">variable_runningcosts</code> |
| <code style="color:green">variable_runningcosts</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 1 |
| |
| |
||
|- |
|- |
||
| <code style="color:green">newtrains</code> |
| <code style="color:green">newtrains</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 1 |
| |
| |
||
|- |
|- |
||
| <code style="color:green">newrvs</code> |
| <code style="color:green">newrvs</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 1 |
| |
| |
||
|- |
|- |
||
| <code style="color:green">newships</code> |
| <code style="color:green">newships</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 1 |
| |
| |
||
|- |
|- |
||
| <code style="color:green">newplanes</code> |
| <code style="color:green">newplanes</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 1 |
| |
| |
||
|- |
|- |
||
| <code style="color:green">newhouses</code> |
| <code style="color:green">newhouses</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 1 |
| |
| |
||
|- |
|- |
||
| <code style="color:green">newindustries</code> |
| <code style="color:green">newindustries</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 1 |
| |
| |
||
|- |
|- |
||
| <code style="color:green">newcargos</code> |
| <code style="color:green">newcargos</code> |
||
| Yes |
| Yes |
||
− | | 0 or 1 |
+ | | {{ttdp|}} 0 or 1 {{ottd|}} Always 1 |
| |
| |
||
|} |
|} |
||
+ | <references /> |
||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ |
Revision as of 22:42, 8 September 2011
Vehicles, Stations, Canals, Bridges, Towns, Houses, Industries (Tiles), Cargos, Airports+Tiles, Objects, Railtypes, Roadtypes, Tramtypes, Terrain
- common props | vars | CBs
- train | roadveh | ship | aircr props
- common variables
- industry props | vars | CBs
- tile props | vars | CBs
- airport props | vars | CBs
- tile props | vars | CBs
General variables
A number of global variables are available. Some are only available in switch-blocks, while others can be used in any expression. This is indicated by the second column in the following table:
name | Available outside switch blocks | Value range | Comment |
---|---|---|---|
ttd_platform
|
Yes | PLATFORM_TTDPATCH or PLATFORM_OPENTTD
|
|
ttdpatch_version
|
Yes | ||
openttd_version
|
Yes | Use version_openttd(MAJOR, MINOR, BUILD) to test and compare for a release version and version_openttd(MAJOR, MINOR, BUILD, REVISION) to test for a specific svn version of OpenTTD
| |
current_palette
|
Yes | PALETTE_DOS or PALETTE_WIN
|
|
current_date
|
No | days since year 0 | Use date(year, month, day) to compare with.
|
current_year
|
No | years since year 0 | |
current_month
|
No | 0 .. 11 | |
current_day_of_month
|
No | 0 .. 30 | |
current_day_of_year
|
No | 0 .. 364 (365 in leap years) | |
is_leapyear
|
No | 0 or 1 | |
date_loaded
|
Yes | days since year 0 | Set to the time of game load, which is the current date in single player, and the date the server started in multiplayer. This to prevent desyncs. |
year_loaded
|
Yes | years since year 0 | See date_loaded .
|
starting_year
|
Yes | years since year 0 | Years before 1920 are clamped to 1920 |
animation_counter
|
No | 0 .. 65535 | Increased by 1 each tick |
climate
|
Yes [1] | CLIMATE_XXX with XXX = [TEMPERATE | ARCTIC | TROPICAL | TOYLAND ]
|
|
game_mode
|
Yes | GAMEMODE_XXX with XXX = [MENU | GAME | EDITOR ]
|
|
loading_stage
|
Yes | LOADING_STAGE_XXX with XXX = [INITIALIZE | RESERVE | ACTIVATE | TEST ]
|
'Phase' of the GRF loading process. |
difficulty_level
|
Yes [1] | DIFFICULTY_XXX with XXX = [EASY | MEDIUM | HARD | CUSTOM ]
|
|
display_options
|
No | bitmask of DISPLAY_XXX with XXX = [TOWN_NAMES | STATION_NAMES | SIGNS | ANIMATION | FULL_DETAIL ]
|
Use hasbit(display_options, DISPLAY_XXX) to test a particular bit.
|
desert_paved_roads
|
Yes [2] | 0 or 1 | If 1, desert roads have pavement and street lights. |
train_width_32_px
|
Yes [2] | 0 or 1 | If 1, train vehicles are 32 instead of 29 pixels wide in the depot view. |
traininfo_y_offset
|
Yes [2] | -128 .. 127 | Used to correctly position the depot view of trains. |
snowline_height
|
No | 16 .. 120 in steps of 8, or 0xFF if no snow. | One tile height is equivalent to 8 units. |
traffic_side
|
Yes [1] | TRAFFIC_SIDE_LEFT or TRAFFIC_SIDE_RIGHT
|
|
freight_trains
|
Yes | 1 .. 255 | Weight multiplier for freight trains |
plane_speed
|
Yes | 1 .. 4 | Speed multiplier for planes. Value of 1 is equal to the original speed (1/4), while 4 means that planes move at full speed (4/4) |
ttdpatch_flags
|
Yes | ||
current_callback
|
No | Set to the ID of the current callback, useful for old-style callbacks. | |
extra_callback_info1
|
No | Varies | Extra callback information, meaning differs per callback. |
extra_callback_info2
|
No | Varies | Extra callback information, meaning differs per callback. |
last_computed_result
|
No | Result of the last (previously evaluated) switch block. | |
base_sprite_2cc
|
Yes | 0 .. 65535 | Base sprite for 2cc (dual company colour) colour-maps |
map_type
|
Yes | MAP_TYPE_XXX with XXX = [RECTANGULAR | X_BIGGER | Y_BIGGER ]
|
|
map_min_edge
|
Yes | 64 .. 2048 | Length of the smallest map edge (in tiles) |
map_max_edge
|
Yes | 64 .. 2048 | Length of the biggest map edge (in tiles) |
map_x_edge
|
Yes | 64 .. 2048 | Length of the x (top-left) map edge (in tiles) |
map_y_edge
|
Yes | 64 .. 2048 | Length of the y (top-right) map edge (in tiles) |
map_size
|
Yes | 64*64 .. 2048*2048 | Total number of tiles on the map |
long_bridges
|
Yes | 0 or 1 | |
gradual_loading
|
Yes | 0 or 1 | |
bridge_speed_limits
|
Yes | 0 or 1 Always 1 | |
signals_on_traffic_side
|
Yes | 0 or 1 | |
electrified_railways
|
Yes | 0 or 1 | |
unified_maglev
|
Yes | 0 .. 3 Always 3 | |
temperate_snowline
|
Yes | 0 or 1 Always 0 | |
dynamic_engines
|
Yes | 0 or 1 | |
variable_runningcosts
|
Yes | 0 or 1 Always 1 | |
newtrains
|
Yes | 0 or 1 Always 1 | |
newrvs
|
Yes | 0 or 1 Always 1 | |
newships
|
Yes | 0 or 1 Always 1 | |
newplanes
|
Yes | 0 or 1 Always 1 | |
newhouses
|
Yes | 0 or 1 Always 1 | |
newindustries
|
Yes | 0 or 1 Always 1 | |
newcargos
|
Yes | 0 or 1 Always 1 |
- ↑ 1.0 1.1 1.2 The value of these variables can change during the game. Reading them from a switch block (which reads the current value) may result in a different value than in the rest of the code (which is evaluated when the game is loaded).
- ↑ 2.0 2.1 2.2 These variables can be written as well as read. Use a normal assignment, for example:
traininfo_y_offset = -2;