Home

LuaRailEnd

Utility object that binds to a rail entity and rail_direction to allow easier traversal over rails

Attributes

rail

Rail to which this RailEnd is binding to.

direction

Which end of the rail this RailEnd is binding to.

location

Location of the rail end

out_signal_location

Location of an outgoing signal, which goes to the right relative to the rail end movement.

alternative_out_signal_location

Location of the alternative outgoing signal, which goes to the right relative to the rail end movement. Not all places have alternative outgoing signal spot, so when it is not available, a nil will be given instead

in_signal_location

Location of an incoming signal, which goes to the left relative to the rail end movement.

alternative_in_signal_location

Location of the alternative incoming signal, which goes to the right relative to the rail end movement. Not all places have alternative incoming signal spot, so when it is not available, a nil will be given instead

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

make_copy

LuaRailEnd.make_copy() -> LuaRailEnd

Call As

railEnd.make_copy()

Call Convention

Creates a copy of this LuaRailEnd object.

Returns

flip_direction

LuaRailEnd.flip_direction()

Call As

railEnd.flip_direction()

Call Convention

Moves to opposite end on the rail this object points to

move_forward

LuaRailEnd.move_forward(connection_direction: defines.rail_connection_direction) -> boolean

Call As

railEnd.move_forward(connection_direction)

Call Convention

Moves forward by 1 rail to the specified connection direction

Parameters

Returns

move_natural

LuaRailEnd.move_natural() -> boolean

Call As

railEnd.move_natural()

Call Convention

Moves forward by 1 rail in the natural direction. Natural direction is a move in the direction taken by the train over rail connection related to this rail end. If there are no trains, the natural direction is straight if straight connected rail exists, otherwise it is right if right connected rail exists, otherwise it is left if left connected rail exists. Natural direction is not defined if there are no rails connected to this end and this method will fail.

Returns

move_to_segment_end

LuaRailEnd.move_to_segment_end()

Call As

railEnd.move_to_segment_end()

Call Convention

Moves forward until a rail segment boundary is reached. If this rail end is at the segment boundary, it will not move at all. When a rail segment is cyclical, it will reach the rail segment boundary at some arbitrary position unless the segment boundary is well defined by presence of rail signals, train stop or other rails connecting to the rails loop.

get_rail_extensions

LuaRailEnd.get_rail_extensions(planner_item: ItemID) -> Array<RailExtensionData>

Call As

railEnd.get_rail_extensions(planner_item)

Call Convention

Returns all possible rail extensions from this position as defined by the planner item.

Parameters

Returns