Railway

Railway

class

Tracks, signals, stations and trains of a surface. Edits go out to the other peers the way the rail tools send them and land at the host's stamped tick

Functions

Railway:is_linked(a, b)

Whether a track runs between the rail nodes standing in two cells

a Vec3i Cell of the first node
b Vec3i Cell of the second node

returns boolean

Railway:set_signal(cell, yaw, kind)

Put a signal on the rail node in a cell, change its kind or take it away, the way the signal tool does

cell Vec3i Cell of the node
yaw number Direction of travel the signal faces, degrees, 0 along +X
kind string? block, chain, or nil to take the signal away

returns boolean True when the edit was taken or the signal is that way already; false when no track runs through the node along that direction

Railway:get_signal(cell, yaw)

Signal on the rail node in a cell facing a direction of travel

cell Vec3i Cell of the node
yaw number Direction of travel, degrees, 0 along +X

returns string? block or chain, nil when there is none

Railway:get_station_name(cell)

Name of the station standing in a cell

cell Vec3i Cell of a platform

returns string? Station name, nil when the cell holds no station

Railway:rename_station(cell, name)

Rename the station standing in a cell the way its window does

cell Vec3i Cell of a platform
name string New name

returns boolean True when the edit was taken; false when the cell holds no station or the name is empty or its own

Railway:place_train(cell, item, cars, reversed)

Put cars on a station the way a car item in hand does: a train standing there takes them at its end, otherwise they make a new train whose only stop is this station. Find the train with get_train_at a tick later

cell Vec3i Cell of a platform
item StaticItem Car item: Locomotive, CargoWagon or TankWagon
cars integer? How many cars, 1 when nil
reversed boolean? Cars face the other way

returns boolean True when the edit was taken; false when the cell holds no station or the item is not a car

Railway:get_trains()

Every train of the surface

returns Train[]

Railway:get_train_at(cell)

Train standing at the station in a cell

cell Vec3i Cell of a platform

returns Train? Train at the station, nil when none stands there

Inherited from Object (5)

Used by