Reference

Scripts & Syntax Reference

Starter scripting patterns verified from the opening tasks: get_component, self, variables, conditions, loops, lists, and machine-local actions.

Starter syntax reference · checked 2026-09-08

Guide artwork of a code-driven planetary automation control room
Guide artwork — not an in-game screenshot.

Quick answer

The early Code: Terraform footage confirms a compact starter toolkit: get_component() to access machines, get_value() to read sensors, self for the current machine, if/else for branching, while True for ongoing automation, and basic lists and dictionaries for scan targets and biology recipes. The biggest rule is that hardware actions usually stay on the machine running the script.

Core building blocks

PatternMeaningStarter example
get_component("name")Fetch another machine/component by nameget_component("clock")
selfThe machine whose script slot is currently runningSolar generator calls its own tilt method
VariableKeep a value for later linessun = clock.get_elevation()
if / elseChoose a branch from a conditionPressure odd/even repair
while TrueKeep a script running continuouslySolar tracker loop
ListOrdered values accessed by indexsites = self.scan() then sites[0]
DictionaryValues stored by keyBiology recipe reagent quantities

The self rule

The biology walkthrough is the clearest example: the collector’s collect action belongs in the collector script, while the biology lab’s analyze/load/extract actions belong in the lab script. A component reference lets one machine pass or receive data without pretending it owns the other machine’s hardware controls.

Three starter patterns worth memorizing

Read → transform → act

Used by the sensor repairs.

raw = sensor.get_value()
fixed = transform(raw)
sensor.calibrate(fixed)

Read state → choose next safe action

Used heavily by the biology loop.

if not self.input:
    self.take_from(collector)
else:
    # inspect the current stage before proceeding
    pass

Continuous control loop

Used by solar tracking.

while True:
    value = clock.get_elevation()
    self.set_tilt_degrees(90 - value)