====== ''train'' Table ====== ''Note'' Information here is incomplete. Please fill in what you know. The ''train'' table describes the state of a train. These tables are stored in the ''advtrains.trains'' table, indexed by the ID of the train. Note that IDs, despite looking like numbers, are stored as strings. The ''train'' table is mainly seen in code where the state of the train is mutated, such as in step functions. Some fields of the ''train'' table are shown below: ^ Key ^ Description ^ Type ^ | ''id'' | Train ID | String | | ''acceleration'' | The acceleration the train is performing | Number, in m/s/s | | ''drives_on'' | A table showing which type of track the train drives on | Table | | ''max_speed'' | The speed a train can go at | Number, in m/s | | ''trainparts'' | Table of wagon IDs of the wagons of the train | Table | | ''is_shunt'' | Train in shunt mode? | Boolean | | ''speed_restriction'' | The speed a train is allowed to go at | Number, in m/s | | ''speed_restrictions_t'' | The speed restrictions applied to the train | Table | | ''routingcode'' | The routing code of a train | String | | ''line'' | The line of a train | String | | ''text_outside'', ''text_inside'' | Outside and inside display texts | String | | ''velocity'' | The speed of a train | Number, in m/s | | ''tarvelocity'' | The target speed of current ATC control | Number, in m/s | | ''last_pos'' | World position of tip of train (to restore path) | Vector | | ''last_connid'' | Connid (see [[dev:core:conns]]) of last_pos pointing forward | Number | | ''last_frac'' | Fractional index offset from last_pos (see [[dev:core:path]]) | Number | | ''atc_command'' | Yet uninterpreted part of current ATC command | String | | ''autocouple'' | Whether train will couple on next collision | Boolean | | ''ars_disable'' | Whether ARS is disabled | Boolean | Dynamic (runtime) values: ^ Key ^ Description ^ Type ^ | ''path'' | table of key-co-ordinate table pairs -> see path.lua | Table | | ''path_cp/cn'', ''path_dist'', ... | auxiliary tables for path -> see path.lua | Table | | ''index'' | Exact position of the front tip of the train on its ''path''. The integer part tells the index in the path table, the fractional part the offset forward towards the next path item | Number | | ''end_index'' | Calculated from ''index'', index of the rear tip of the train | Number | | ''no_step'' | If true, train skips all train steps (used for trains whose track is not found) | Boolean | | ''lever'' | The current lever value (as determined either by user control or by ATC/LZB) | Number (enum-like) | | ''ctrl_user'' | The lever input from the player (train driver) if present | Number (enum-like) | | ''lzb'' | State table of LZB subsystem (see lzb.lua) | Table |