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
Last revision Both sides next revision
dev:core:train [2023-01-11 16:28]
56independent Add some more data i find relevant
dev:core:train [2023-01-12 11:56]
ywang
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 |+| ''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'' | The carriages in a 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  | ?+| ''velocity'' | The speed of a train | Number, in m/s | 
-| ''brake'' | Wether brakes are enabled | bool +| ''movedir'' | Direction of movement (see notes below) Number (?
-| ''path'' | table of key-co-ordinate table pairs | table +| ''brake'' | Wether brakes are enabled | Boolean 
-| ''id'' | Train ID | string |+| ''path'' | table of key-co-ordinate table pairs | Table 
 +| ''id'' | Train ID | String | 
 + 
 +Note that the ''movedir'' field is no longer set. The only reference found in the current source code suggests that the field is used to indicate the direction of the train as a binary state.
dev/core/train.txt · Last modified: 2023-05-24 22:57 by orwell