User Tools

Site Tools


dev:core:train

Differences

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

Link to this comparison view

Next revision
Previous revision
dev:core:train [2023-01-11 14:14]
56independent created to the best of my ability and knowledge
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 1: Line 1:
-====== `trainTable ======+====== ''train'' Table ======
 ''Note'' Information here is incomplete. Please fill in what you know. ''Note'' Information here is incomplete. Please fill in what you know.
  
-The `traintable 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 
-`speed_restriction| The speed a train is allowed to go at | m/s | +''id'' | Train ID | String | 
-`routingcode| The routing code of a train | Minetest text encoding +| ''acceleration'' | The acceleration the train is performing | Number, in m/s/s | 
-`line| The line of a train | Minetest text encoding +| ''drives_on'' | A table showing which type of track the train drives on | Table | 
-`velocity| The speed of a train | m/s | +| ''max_speed'' | The speed a train can go at | Number, in m/s | 
-`movedir` Direction of movement  ?? +| ''trainparts'' | Table of wagon IDs of the wagons of the train | Table | 
-`brake` Wether brakes are enabled bool |+| ''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 |
dev/core/train.1673442879.txt.gz · Last modified: 2023-01-11 14:14 by 56independent