Home

LuaTrainManager

The train manager manages all the train in the game. LuaTrainManager allows to perform some direct queries to the train manager.

There is always exactly one train manager instance in a game, it can be obtained from LuaGameScript::train_manager. This object is always valid and is equal to any other instance of LuaTrainManager from this game.

Attributes

valid

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.

object_name

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.

Methods

get_train_by_id

LuaTrainManager.get_train_by_id(train_id: uint32) -> LuaTrain?

Call As

trainManager.get_train_by_id(train_id)

Call Convention

Searches for a train with given ID.

Parameters

Returns

get_trains

LuaTrainManager.get_trains(filter: TrainFilter) -> Array<LuaTrain>

Call As

trainManager.get_trains(filter)

Call Convention

Gets all trains that pass given filter

Parameters

Returns

get_train_stops

LuaTrainManager.get_train_stops(filter: TrainStopFilter) -> Array<LuaEntity>

Call As

trainManager.get_train_stops(filter)

Call Convention

Gets all train stops that pass given filter

Parameters

Returns

request_train_path

LuaTrainManager.request_train_path{ type?: TrainPathRequestType, train?: LuaTrain, goals: Array<TrainPathFinderGoal>, return_path?: boolean, starts?: Array<RailEndStart>, search_direction?: "respect-movement-direction" | "any-direction-with-locomotives", in_chain_signal_section?: boolean, steps_limit?: uint32, shortest_path?: boolean } -> TrainPathFinderOneGoalResult | TrainPathAllGoalsResult

Call As

trainManager.request_train_path{ goals=goals }

Call Convention

Direct access to train pathfinder. Allows to search rail paths or querying which stops are accessible

Parameters

Returns