StarOS reference
StarOS runs your scripts. The language is Starlark: it reads like Python and it is deterministic. It has no clock, no random numbers, no files and no load. A script sees only the names the server gives it. New to it? Read the primer first.
How a script runs
A script defines def tick(): with no parameters. The server calls it once a turn.
def tick():
robot.log("turn " + str(robot.turn))
- Every script of a turn reads the same snapshot, taken at the start of the turn.
- A call such as
robot.moveordrill.digrecords an intention. The world changes after the scripts have run. - Global variables do not survive between turns. memory does.
- Sets and
whileloops work. Recursion does not. - If a script fails, only that host is affected: its intentions and memory writes of that turn are dropped.
- A saved script runs from the next turn. The editor reports compile errors with line and column.
json and math, the standard Starlark modules, are always there.
Modules every robot has
| module | page |
|---|---|
robot |
robot |
memory |
memory |
sun |
sun |
wallet |
wallet |
power |
power |
industry |
industry |
storage |
storage |
contract, relay |
contract and relay |
turret |
combat |
Modules that come with a part
A part you did not attach is not a name: using it is a compile error.
| part | module | page |
|---|---|---|
lidar |
lidar |
lidar |
drill or drill_mk2 |
drill |
drill |
hopper |
hopper |
hopper |
battery_cell |
battery |
battery |
modem |
net, llm, jev |
net, llm, jev |
modem |
market |
market |
builder |
builder |
builder |
crane |
crane |
crane |
assay_probe |
assay |
assay |
soil_preparer, planter, weeder, harvester |
soil, planter, weeder, harvester |
farming |
laser, railgun, armor_plate, shield_emitter, jammer |
laser, railgun, armor, shield, jammer |
combat |
wheels, tracks |
mobility |
robot |
Other hosts
Trains, power stations, wormhole gates, signals, spacecraft and contracts run scripts too, with their own modules: see other hosts and contract and relay.
More
- Cookbook: eight complete scripts.
- Limits: every cap in one place.
- Troubleshooting: what each outcome means.
What does not exist
There is no hauler script (a hauler takes orders from you, not from StarOS) and no sensors module. Your spacecraft's sensors work by themselves.
The game also generates a reference from the code that runs your scripts: on a part's page, on your robot's page, or through the staros_reference tool of your AI agent. When it disagrees with these pages, it wins.