User Tools

Site Tools


dev:core:train

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
dev:core:train [2023-01-11 16:28]
56independent Add some more data i find relevant
dev:core:train [2023-05-24 22:57] (current)
orwell Add more fields, remove some fields that have been removed in the tss update
Line 2: Line 2:
 ''Note'' Information here is incomplete. Please fill in what you know. ''Note'' Information here is incomplete. Please fill in what you know.
  
-The ''train'' table is an essential table to Advtrains.+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.
  
-''train'' itself is a shorthand used as an argument in many functions for ''advtrains.trains[id]'', where ''[id]'' is the id of train.+The ''train'' table is mainly seen in code where the state of the train is mutated, such as in step functions.
  
-''train'' holds a whole array of information about the train, some shown below:+Some fields of the ''train'' table are shown below:
  
-^ Key ^ Description ^ Unit +^ Key ^ Description ^ Type ^ 
-| ''acceleration'' | The acceleration the train is performing | m/s/s |+| ''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 | | ''drives_on'' | A table showing which type of track the train drives on | Table |
-| ''max_speed'' | The speed a train can go at | m/s | +| ''max_speed'' | The speed a train can go at | Number, in m/s | 
-| ''trainparts''The carriages in a train | table +| ''trainparts''Table of wagon IDs of the wagons of the train | Table 
-| ''is_shunt'' | Train in shunt mode? | bool +| ''is_shunt'' | Train in shunt mode? | Boolean 
-| ''speed_restriction'' | The speed a train is allowed to go at | m/s | +| ''speed_restriction'' | The speed a train is allowed to go at | Number, in m/s 
-| ''routingcode'' | The routing code of a train | Minetest text encoding +| ''speed_restrictions_t'' | The speed restrictions applied to the train | Table 
-| ''line'' | The line of a train | Minetest text encoding +| ''routingcode'' | The routing code of a train | String 
-| ''velocity'' | The speed of a train | m/s | +| ''line'' | The line of a train | String | 
-| ''movedir''Direction of movement  ?? +| ''text_outside'', ''text_inside'' | Outside and inside display texts | String 
-| ''brake''Wether brakes are enabled bool +| ''velocity'' | The speed of a train | Number, in m/s | 
-| ''path'' | table of key-co-ordinate table pairs | table | +| ''tarvelocity''The target speed of current ATC control Number, in m/s 
-| ''id''Train ID string |+| ''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 |
dev/core/train.1673450927.txt.gz · Last modified: 2023-01-11 16:28 by 56independent