Closely mimics GRF/NFO capabilites.
https://newgrf-specs.tt-wiki.net/wiki/Features
Actions 0-4 all take feature
argument to specify OpenTTD feature they're working with.
Use one of the TRAIN, RV, SHIP, AIRCRAFT, STATION, RIVER, BRIDGE, HOUSE, GLOBAL_VAR, INDUSTRY_TILE, INDUSTRY, CARGO, SOUND_EFFECT, AIRPORT, SIGNAL, OBJECT, RAILTYPE, AIRPORT_TILE, ROADTYPE, TRAMTYPE
predefined constants of a Feature
type.
For some actions feature
argument is optional, but in that case they must be referenced by another action with a defined feature.
Some actions take ref_id
argument that can be used to reference them from other actions (in GRF specs it's called set-id
). You can either specify it manually or just let grf-py set the ID for you. When referencing another action you can either use Ref(id)
object to reference it by the ID or store that action in a variable and use it directly.
https://newgrf-specs.tt-wiki.net/wiki/Action0 Documentation on properties.
id
- The ID of entity to define.props
- dict of entity properties.
first_id
- The ID of first entity to define.props
- Dict of lists of properties to change. Each list should containcount
elements.count
- Amount of entities to define. If None the length of props lists is used.
https://newgrf-specs.tt-wiki.net/wiki/Action1
count
- Amount of sprites.
set_count
- Amount of sets of sprites.sprite_count
- Amount of sprites in each set.
https://newgrf-specs.tt-wiki.net/wiki/Action2
ground
- GroundSprite
.buildigns
- List of buildingSprite
s.
ground
- GroundSprite
.buildigns
- List of buildingSprite
s.has_flags
- TODO
https://newgrf-specs.tt-wiki.net/wiki/VarAction2Advanced Functional equivalent of nml switch statement.
code
- Code of the expression to evaluate. TODO language docs.ranges
- Either list ofRange
instances or dict with keys being integers or tuples(low, high)
andRef
orCB
values. Integer value is the same as usingCB
.default
- Default value to use if no ranges match.related_scope
- Whether to resolve variable against current object or the related one.
RandomSwitch(*, scope, triggers, cmp_all, lowest_bit, groups, count=None, feature=None, ref_id=None)
https://newgrf-specs.tt-wiki.net/wiki/RandomAction2
scope
- scope of the switch, either'self'
,'relative'
, orparent
.triggers
- TODOcmp_all
- TODOlowest_bit
- TODOgroups
- List of actions to choose from.count
- TODO
https://newgrf-specs.tt-wiki.net/wiki/Action2/Industries
https://newgrf-specs.tt-wiki.net/wiki/Action3
ids
- ID of the entities to associate graphics withmaps
- cargo type to ref ID dictdefault
- default ref ID
definition
- entity (action 0) to map graphics formaps
- cargo type to ref ID dictdefault
- default ref ID
https://newgrf-specs.tt-wiki.net/wiki/Action4
offset
- ID of the first string to changeis_generic_offset
- TODO (0x80 in lang)strings
- list of stringslang
- language indentifier
https://newgrf-specs.tt-wiki.net/wiki/Action5
set_type
- type of the graphics.count
- number of sprites to replace.offset
- offset in the assignable block of sprites (to replace only a subset of sprites).
https://newgrf-specs.tt-wiki.net/wiki/Action6
params
- list of dicts with param info with keys 'num', 'size', 'offset'.
https://newgrf-specs.tt-wiki.net/wiki/Action7
is_static
- True for action 9, False for 7.variable
- variable to base the decision on.condition
- condition type.value
- what the variable is compared to.skip
- how many sprites will be skipped.varsize
- TODO
https://newgrf-specs.tt-wiki.net/wiki/Action8
grfid
- a unique ID for your .grf file (4 bytes).name
- name of the GRF.description
format_version
- GRF format version (int).
https://newgrf-specs.tt-wiki.net/wiki/ActionA
sets
(list, tuple) - a list of pairs (first, num) defining the sets of sprites to replace
https://newgrf-specs.tt-wiki.net/wiki/ActionB
severity
lang
message
text_param
params
https://newgrf-specs.tt-wiki.net/wiki/ActionC
data
- content of the comment, has no effect on the GRF functionality.
https://newgrf-specs.tt-wiki.net/wiki/ActionD
https://newgrf-specs.tt-wiki.net/wiki/ActionE Unsupported (TODO)
https://newgrf-specs.tt-wiki.net/wiki/ActionF Unsupported (TODO)
https://newgrf-specs.tt-wiki.net/wiki/Action10
label
(int 0..255) - ID of the labelcomment
(bytes) - optional comment, ignored by the game
https://newgrf-specs.tt-wiki.net/wiki/Action11
count
- number of sound effects that follow
Special action that can follow SoundEffects
to refer to a sound in another GRF.
https://newgrf-specs.tt-wiki.net/wiki/Action12
glyphs
- List of dicts with 'font', 'count' and 'base' keys.
https://newgrf-specs.tt-wiki.net/wiki/Action13
https://newgrf-specs.tt-wiki.net/wiki/Action14
props
(dict) - Nested dicts of properties. All keys must be 4 bytes, values either int, bytes, string, tuple or another dict. If the value is tuple it must be a pair of(lang_id, str)
.