train module

Functions for working with trains.

See also

Usage

local train = require("__flib__.train")

Functions

get_main_locomotive(train) Get the main locomotive in a given train.
get_backer_name(train) Get the backer_name of the main locomotive in a given train.
rotate_carriage(entity) Rotate a single carriage of a train.
get_composition_string(train) Create a string representing train composition.
open_gui(player_index, train) Open train GUI for one player.

Concepts

TrainCompositionCounts

Functions

# get_main_locomotive(train)

Get the main locomotive in a given train.

Parameters: Returns:
# get_backer_name(train)

Get the backer_name of the main locomotive in a given train.

Parameters: Returns:
# rotate_carriage(entity)

Rotate a single carriage of a train.

Parameters: Returns:
  • (boolean) Whether or not the rotation was successful.
# get_composition_string(train)

Create a string representing train composition.

‘<L<’ and ‘>L>’ for locomotives, ‘C’ for cargo wagons, ‘F’ for fluid wagons, ‘A’ for artillery wagon.

Parameters: Returns:
# open_gui(player_index, train)

Open train GUI for one player.

Parameters:
  • player_index : number
  • train : (LuaTrain)
Returns:

Concepts

# TrainCompositionCounts

A table with the following fields:

  • total : (number) The total number of rolling stocks in the train.
  • wagons : (number) The number of wagons in the train.
  • front_movers : (number) The number of front-facing locomotives in the train.
  • back_movers : (number) The number of back-facing locomotives in the train.