pub struct LuaTrain;Expand description
A train. Trains are a sequence of connected rolling stocks – locomotives and wagons.
Implementations§
Source§impl LuaTrain
impl LuaTrain
Sourcepub fn back_end(&self) -> LuaRailEnd
pub fn back_end(&self) -> LuaRailEnd
Back end of the train: Rail and direction on that rail where the train will go when moving backward
Sourcepub fn back_stock(&self) -> LuaEntity
pub fn back_stock(&self) -> LuaEntity
The back stock of this train, if any. The back of the train is at the opposite end of the front.
Sourcepub fn cargo_wagons(&self) -> Vec<LuaEntity>
pub fn cargo_wagons(&self) -> Vec<LuaEntity>
The cargo carriages the train contains.
Sourcepub fn carriages(&self) -> Vec<LuaEntity>
pub fn carriages(&self) -> Vec<LuaEntity>
The rolling stocks this train is composed of, with the numbering starting at the front of the train.
Sourcepub fn fluid_wagons(&self) -> Vec<LuaEntity>
pub fn fluid_wagons(&self) -> Vec<LuaEntity>
The fluid carriages the train contains.
Sourcepub fn front_end(&self) -> LuaRailEnd
pub fn front_end(&self) -> LuaRailEnd
Front end of the train: Rail and direction on that rail where the train will go when moving forward
Sourcepub fn front_stock(&self) -> LuaEntity
pub fn front_stock(&self) -> LuaEntity
The front stock of this train, if any. The front of the train is in the direction that a majority of locomotives are pointing in. If it’s a tie, the North and West directions take precedence.
Sourcepub fn group(&self) -> &str
pub fn group(&self) -> &str
The group this train belongs to.
Setting the group will apply the schedule of the group to this train.
Sourcepub fn kill_count(&self) -> u32
pub fn kill_count(&self) -> u32
The total number of kills by this train.
Sourcepub fn killed_players(&self) -> LuaAny
pub fn killed_players(&self) -> LuaAny
The players killed by this train.
The keys are the player indices, the values are how often this train killed that player.
Sourcepub fn locomotives(&self) -> LuaTrainLocomotives
pub fn locomotives(&self) -> LuaTrainLocomotives
Locomotives of the train.
Sourcepub fn manual_mode(&self) -> bool
pub fn manual_mode(&self) -> bool
When true, the train is explicitly controlled by the player or script. When false, the train moves autonomously according to its schedule.
Sourcepub fn max_backward_speed(&self) -> f64
pub fn max_backward_speed(&self) -> f64
Current max speed when moving backwards, depends on locomotive prototype and fuel.
Sourcepub fn max_forward_speed(&self) -> f64
pub fn max_forward_speed(&self) -> f64
Current max speed when moving forward, depends on locomotive prototype and fuel.
Sourcepub fn object_name(&self) -> &str
pub fn object_name(&self) -> &str
The class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.
Sourcepub fn passengers(&self) -> Vec<LuaPlayer>
pub fn passengers(&self) -> Vec<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.
Sourcepub fn path(&self) -> LuaRailPath
pub fn path(&self) -> LuaRailPath
The path this train is using, if any.
Sourcepub fn path_end_rail(&self) -> LuaEntity
pub fn path_end_rail(&self) -> LuaEntity
The destination rail this train is currently pathing to, if any.
Sourcepub fn path_end_stop(&self) -> LuaEntity
pub fn path_end_stop(&self) -> LuaEntity
The destination train stop this train is currently pathing to, if any.
Sourcepub fn riding_state(&self) -> RidingState
pub fn riding_state(&self) -> RidingState
The riding state of this train.
Sourcepub fn schedule(&self) -> TrainSchedule
pub fn schedule(&self) -> TrainSchedule
This train’s current schedule, if any. Set to nil to clear.
The schedule can’t be changed by modifying the returned table. Instead, changes must be made by assigning a new table to this attribute.
This is a simplified schedule that does not include train groups and interrupts. See LuaTrain::get_schedule for full access to the train schedule, including interrupts and train groups.
Sourcepub fn speed(&self) -> f64
pub fn speed(&self) -> f64
Current speed.
Changing the speed of the train is potentially an unsafe operation because train uses the speed for its internal calculations of break distances, etc.
Sourcepub fn valid(&self) -> bool
pub fn valid(&self) -> bool
Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.
Sourcepub fn clear_fluids_inside(&self)
pub fn clear_fluids_inside(&self)
Clears all fluids in this train.
Sourcepub fn clear_items_inside(&self)
pub fn clear_items_inside(&self)
Clear all items in this train.
Sourcepub fn get_contents(&self) -> Vec<ItemWithQualityCount>
pub fn get_contents(&self) -> Vec<ItemWithQualityCount>
Get a mapping of the train’s inventory.
Sourcepub fn get_fluid_contents(&self) -> HashMap<String, LuaAny>
pub fn get_fluid_contents(&self) -> HashMap<String, LuaAny>
Gets a mapping of the train’s fluid inventory.
Sourcepub fn get_fluid_count(&self, fluid: Option<&str>) -> f64
pub fn get_fluid_count(&self, fluid: Option<&str>) -> f64
Get the amount of a particular fluid stored in the train.
Sourcepub fn get_item_count(&self, item: Option<ItemFilter>) -> u32
pub fn get_item_count(&self, item: Option<ItemFilter>) -> u32
Get the amount of a particular item stored in the train.
Sourcepub fn get_rail_end(&self, direction: &str) -> LuaRailEnd
pub fn get_rail_end(&self, direction: &str) -> LuaRailEnd
Gets a LuaRailEnd object pointing away from the train at specified end of the train
Sourcepub fn get_schedule(&self) -> LuaSchedule
pub fn get_schedule(&self) -> LuaSchedule
This allows full access to the train schedule, including modifying the schedule records, the train group and the interrupts.
Sourcepub fn go_to_station(&self, index: u32)
pub fn go_to_station(&self, index: u32)
Go to the station specified by the index in the train’s schedule.
Sourcepub fn insert_fluid(&self, fluid: Fluid) -> f64
pub fn insert_fluid(&self, fluid: Fluid) -> f64
Inserts the given fluid into the first available location in this train.
Sourcepub fn recalculate_path(&self, force: Option<bool>) -> bool
pub fn recalculate_path(&self, force: Option<bool>) -> bool
Checks if the path is invalid and tries to re-path if it isn’t.
Sourcepub fn remove_fluid(&self, fluid: Fluid) -> f64
pub fn remove_fluid(&self, fluid: Fluid) -> f64
Remove some fluid from the train.
Sourcepub fn remove_item(&self, stack: LuaAny) -> u32
pub fn remove_item(&self, stack: LuaAny) -> u32
Remove some items from the train.