get_item_count(item?) changed | → uint | Get the amount of a particular item stored in the train. |
Get the amount of a particular item stored in the train. | ||
get_contents() changed | → array[ItemWithQualityCounts] | Get a mapping of the train's inventory. |
Get a mapping of the train's inventory. | ||
remove_item(stack) | → uint | Remove some items from the train. |
Remove some items from the train. | ||
insert(stack) | Insert a stack into the train. | |
Insert a stack into the train. | ||
clear_items_inside() | Clear all items in this train. | |
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. |
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 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. |
Gets a mapping of the train's fluid inventory. | ||
remove_fluid(fluid) | → double | Remove some fluid from the train. |
Remove some fluid from the train. | ||
insert_fluid(fluid) | → double | Inserts the given fluid into the first available location in this train. |
Inserts the given fluid into the first available location in this train. | ||
clear_fluids_inside() | Clears all fluids in this train. | |
Clears all fluids in this train. | ||
go_to_station(index) | Go to the station specified by the index in the train's schedule. | |
Go to the station specified by the index in the train's schedule. | ||
get_rails() | → array[LuaEntity] | Gets all rails under the train. |
Gets all rails under the train. | ||
get_rail_end(direction) new | → LuaRailEnd | Gets a LuaRailEnd object pointing away from the train at specified end of the train |
Gets a LuaRailEnd object pointing away from the train at specified end of the train | ||
manual_mode | :: RW boolean | When |
When | ||
speed | :: RW double | Current speed. [...] |
Current speed. [...] | ||
max_forward_speed | :: R double | Current max speed when moving forward, depends on locomotive prototype and fuel. |
Current max speed when moving forward, depends on locomotive prototype and fuel. | ||
max_backward_speed | :: R double | Current max speed when moving backwards, depends on locomotive prototype and fuel. |
Current max speed when moving backwards, depends on locomotive prototype and fuel. | ||
weight | :: R double | The weight of this train. |
The weight of this train. | ||
carriages | :: R array[LuaEntity] | The rolling stocks this train is composed of, with the numbering starting at the front of the train. |
The rolling stocks this train is composed of, with the numbering starting at the front of the train. | ||
locomotives | :: R table | Locomotives of the train. |
Locomotives of the train. | ||
cargo_wagons | :: R array[LuaEntity] | The cargo carriages the train contains. |
The cargo carriages the train contains. | ||
fluid_wagons | :: R array[LuaEntity] | The fluid carriages the train contains. |
The fluid carriages the train contains. | ||
schedule | :: RW TrainSchedule? | This train's current schedule, if any. [...] |
This train's current schedule, if any. [...] | ||
state | :: R defines.train_state | This train's current state. |
This train's current state. | ||
front_stock | :: R LuaEntity? | The front stock of this train, if any. [...] |
The front stock of this train, if any. [...] | ||
back_stock | :: R LuaEntity? | The back stock of this train, if any. [...] |
The back stock of this train, if any. [...] | ||
station | :: R LuaEntity? | The train stop this train is stopped at, if any. |
The train stop this train is stopped at, if any. | ||
has_path | :: R boolean | If this train has a path. |
If this train has a path. | ||
path_end_rail | :: R LuaEntity? | The destination rail this train is currently pathing to, if any. |
The destination rail this train is currently pathing to, if any. | ||
path_end_stop | :: R LuaEntity? | The destination train stop this train is currently pathing to, if any. |
The destination train stop this train is currently pathing to, if any. | ||
id | :: R uint | The unique train ID. |
The unique train ID. | ||
passengers | :: R array[LuaPlayer] | The player passengers on the train This does not index using player index. See LuaPlayer::index on each player instance for the player index. |
The player passengers on the train This does not index using player index. See LuaPlayer::index on each player instance for the player index. | ||
riding_state | :: R RidingState | The riding state of this train. |
The riding state of this train. | ||
killed_players | :: R dictionary[uint → uint] | The players killed by this train. [...] |
The players killed by this train. [...] | ||
kill_count | :: R uint | The total number of kills by this train. |
The total number of kills by this train. | ||
path | :: R LuaRailPath? | The path this train is using, if any. |
The path this train is using, if any. | ||
signal | :: R LuaEntity? | The signal this train is arriving or waiting at, if any. |
The signal this train is arriving or waiting at, if any. | ||
group new | :: RW string | The group this train belongs to. [...] |
The group this train belongs to. [...] | ||
front_end new | :: R LuaRailEnd | Front end of the train: Rail and direction on that rail where the train will go when moving forward |
Front end of the train: Rail and direction on that rail where the train will go when moving forward | ||
back_end new | :: R LuaRailEnd | Back end of the train: Rail and direction on that rail where the train will go when moving backward |
Back end of the train: Rail and direction on that rail where the train will go when moving backward | ||
valid | :: R boolean | Is this object valid? [...] |
Is this object valid? [...] | ||
object_name | :: R string | The class name of this object. [...] |
The class name of this object. [...] |
stack | :: ItemStackIdentification | The amount and type of items to remove |
The amount and type of items to remove |
→ uint | Number of items actually removed. |
fluid | :: string? | Fluid name to count. If not given, counts all fluids. |
Fluid name to count. If not given, counts all fluids. |
front_movers | :: array[LuaEntity] | Array of locomotives. |
Array of locomotives. | ||
back_movers | :: array[LuaEntity] | Array of locomotives. |
Array of locomotives. |
-- called on a LuaTrain with 3 locomotives, it returns 3 LuaEntities:
train.locomotives -- => {front_movers = {loco1, loco2}, back_movers = {loco3}}