Railway
classTracks, 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:link(a, b)
Lay a track between the rail nodes standing in two cells the way the rail tool does, bending the tracks already at the nodes to meet it
| a | Vec3i | Cell of the first node |
| b | Vec3i | Cell of the second node |
returns boolean True when the edit was taken or the nodes are linked already; false when a cell holds no node or the track does not fit
Railway:unlink(a, b)
Take away the track between the rail nodes standing in two cells the way the rail tool does
| a | Vec3i | Cell of the first node |
| b | Vec3i | Cell of the second node |
returns boolean True when the edit was taken; false when no track runs there, it is a platform or a train stands on it
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_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)
- name read-only Object name
- Object.find(name) Find an already loaded object by name
- Object.cast(object) Trying to cast Object into Object
- Object:get_class() Class of this object
- Object.get_class() Return Object class object
Used by
- Dimension.get_railway return