Skip to content

Quick start

Lycoris edited this page Nov 10, 2026 · 1 revision

Quick start

Put a computer inside the cart, then run this. It reads the train, parks it at a station and gives control back. The station name is an example, use one from your own railway.

local train = loconautics.getTrain()
print(train.getName(), train.getStationState())

train.parkAtStation("Central")
repeat os.sleep(0.2) until not train.isParking()
train.release()

The first line is the handle every other example in this guide starts from, see Getting a handle. Driving needs a built drivetrain, reading does not.

Finding what you need

I want to Go to
Get a train to talk to Getting a handle
Know how units, nil and errors work Conventions
Read speed, slope, mass or power Motion
Know if it is derailed, braked or held State
Know where it is stopped, and for how long Station
Measure the distance to the next signal Signals
Find the end of the track, a bend, a hill or a sub level track ahead Track ahead
Read its direction, tilt or world position Orientation, World position
Count cargo, fluid and passengers Carriages, Consist wide cargo
Drive by hand Drivetrain, Who owns the train, Manual control
Stop the train Braking
Send it to a station or a point on the track Parking
Get the distance or turns to a station Routing and distance
Read or write a schedule Schedule, Writing a schedule
Open the doors Doors
Tilt or shift the carriage body Body offset
Send or receive Create link signals Frequencies, Redstone links
List every train, signal and track piece Network
Run signals, points and trains from a desk Controlling the network
Wait for an arrival, a derail or a red Events
Copy a working program Examples, Full programs
Look up a word Glossary

Clone this wiki locally