A train. Trains are a sequence of connected rolling stocks -- locomotives and wagons.
get_item_count(item) → uint | Get the amount of a particular item stored in the train. |
get_contents() → dictionary[string → uint] | Get a mapping of the train's inventory. |
remove_item(stack) → uint | Remove some items from the train. |
insert(stack) | Insert a stack into the train. |
clear_items_inside() | Clear all items in this train. |
recalculate_path(force) → boolean | Checks if the path is invalid and tries to re-path if it isn't. |
get_fluid_count(fluid) → double | Get the amount of a particular fluid stored in the train. |
get_fluid_contents() → dictionary[string → double] | Gets a mapping of the train's fluid inventory. |
remove_fluid(fluid) → double | Remove some fluid from the train. |
insert_fluid(fluid) → double | Inserts the given fluid into the first available location in this train. |
clear_fluids_inside() | Clears all fluids in this train. |
go_to_station(index) | Go to the station specified by the index in the train's schedule. |
get_rails() → array[LuaEntity] | Gets all rails under the train. |
manual_mode :: boolean [RW] | When true , the train is explicitly controlled by the player or script. |
speed :: double [RW] | Current speed. |
max_forward_speed :: double [R] | Current max speed when moving forward, depends on locomotive prototype and fuel. |
max_backward_speed :: double [R] | Current max speed when moving backwards, depends on locomotive prototype and fuel. |
weight :: double [R] | The weight of this train. |
carriages :: array[LuaEntity] [R] | Rolling stocks the train is composed of. |
locomotives :: dictionary[string → array[LuaEntity]] [R] | Arrays of locomotives. |
cargo_wagons :: array[LuaEntity] [R] | The cargo carriages the train contains. |
fluid_wagons :: array[LuaEntity] [R] | The fluid carriages the train contains. |
schedule :: TrainSchedule [RW] | The trains current schedule or nil if empty. |
state :: defines.train_state [R] | This train's current state. |
front_rail :: LuaEntity [R] | The rail at the front end of the train, possibly nil . |
back_rail :: LuaEntity [R] | The rail at the back end of the train, possibly nil . |
rail_direction_from_front_rail :: defines.rail_direction [R] | |
rail_direction_from_back_rail :: defines.rail_direction [R] | |
front_stock :: LuaEntity [R] | The front stock of this train or nil . |
back_stock :: LuaEntity [R] | The back stock of this train or nil . |
station :: LuaEntity [R] | The train stop this train is stopped at or nil . |
has_path :: boolean [R] | If this train has a path. |
path_end_rail :: LuaEntity [R] | The destination rail this train is currently pathing to or nil . |
path_end_stop :: LuaEntity [R] | The destination train stop this train is currently pathing to or nil . |
id :: uint [R] | The unique train ID. |
passengers :: array[LuaPlayer] [R] | The player passengers on the train |
riding_state :: RidingState [R] | The riding state of this train. |
killed_players :: dictionary[uint → uint] [R] | The players killed by this train. |
kill_count :: uint [R] | The total number of kills by this train. |
path :: LuaRailPath [R] | The path this train is using or nil if none. |
signal :: LuaEntity [R] | The signal this train is arriving or waiting at or nil if none. |
valid :: boolean [R] | Is this object valid? |
object_name :: string [R] | The class name of this object. |
help() → string | All methods and properties that this object supports. |
Get the amount of a particular item stored in the train.
Get a mapping of the train's inventory.
Remove some items from the train.
Clear all items in this train.
Checks if the path is invalid and tries to re-path if it isn't.
Get the amount of a particular fluid stored in the train.
Gets a mapping of the train's fluid inventory.
Remove some fluid from the train.
Inserts the given fluid into the first available location in this train.
Clears all fluids in this train.
Go to the station specified by the index in the train's schedule.
Gets all rails under the train.
When true
, the train is explicitly controlled by the player or script. When false
, the
train moves autonomously according to its schedule.
Current speed.
Current max speed when moving forward, depends on locomotive prototype and fuel.
Current max speed when moving backwards, depends on locomotive prototype and fuel.
The weight of this train.
Rolling stocks the train is composed of.
Arrays of locomotives. The result is two arrays, indexed by "front_movers"
and "back_movers"
containing the locomotives. E.g. {front_movers={loco1, loco2}, back_movers={loco3}}
.
The cargo carriages the train contains.
The fluid carriages the train contains.
The trains current schedule or nil
if empty. Set to nil
to clear.
This train's current state.
The rail at the front end of the train, possibly nil
.
The rail at the back end of the train, possibly nil
.
The front stock of this train or nil
.
The back stock of this train or nil
.
The train stop this train is stopped at or nil
.
If this train has a path.
The destination rail this train is currently pathing to or nil
.
The destination train stop this train is currently pathing to or nil
.
The unique train ID.
The player passengers on the train
The riding state of this train.
The players killed by this train.
The keys are the player indexes, the values are how often this train killed that player.
The total number of kills by this train.
The path this train is using or nil
if none.
The signal this train is arriving or waiting at or nil
if none.