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-13

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

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.

The language in one paragraph

Code: Terraform uses a Python-like scripting language running on the developer’s own interpreter — recorded sessions describe it as Python influenced rather than pure Python, and one detail proves the difference matters: one recorded build rejected a lowercase true and required Python-style True (treat capital True as the safe default, to be confirmed across builds). Colons end condition lines with no then, and indentation defines blocks exactly as in Python.

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
for x in listIterate a collectionfor site in sites:
for x in range(n)Count through numbersRecorded session iterating grid cells
ListOrdered values accessed by indexsites = self.scan() then sites[0]
DictionaryValues stored by keyBiology recipe reagent quantities
Conditional expressionInline branch: a if cond else bRecorded one-line pressure repair

Editor facts from recorded sessions

  • Tab autocompletes component and method names; Shift+Enter runs the current script or console line.
  • Comments start with # — recorded sessions confirm commented lines do not change values.
  • print joins multiple values with spaces; f-style strings (f"...{value}...") also work and are what one recording used to format specimen readouts.
  • sleep(seconds) takes a number and is optional pacing: the interpreter automatically yields time to other scripts, so loops do not starve the rest of the base.
  • Console output and result panes can be docked/undocked; recordings show players losing track of the console window more than once.

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. The recorded docs list the hardware actions that stay machine-local — collect, analyze, extract, load, sell, move, drill, charge — and mark them self only. A script may read or pass a component reference to another machine (the lab takes from the collector via a reference), but it should not drive the other machine’s hardware directly.

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)

When syntax errors appear

The error messages recorded on camera — expected indent at start of block, list index must be an integer, unexpected character — and their fixes are catalogued in the common errors reference. One recorded session also lost a whole repair to a single misplaced parenthesis, which is the strongest argument for building the multi-line version first and collapsing to one-liners only after it works.

Patch note: build 0.1.22 (September 13, 2026)

The first post-launch patch expanded the scripting layer, which is why this page is worth re-reading after you update:

  • Component types, build versions and upcoming orders got broader script support, and marker arguments were fixed — copy that was rejected before may now parse.
  • Larger script operations, generator handling and shared-data updates were repaired.
  • Console errors are clearer, script filtering and boot-script output were fixed.
  • VS Code integration and other external editors were added, with script controls, debugging and more reliable syncing — plus manual exports to PDF, HTML and Markdown, and a DOCS shortcut in-game.

The language itself is unchanged: self, if/else, while True, lists and dictionaries still behave as recorded. Only the tooling around it moved.

Evidence and version notes

Everything on this page is from recorded playthroughs of the closed testing and public demo builds (September 2026), plus the developer’s own 0.1.22 release notes (September 13, 2026) for the editor and tooling changes. The Early Access build launched September 9, 2026 and the developer changed documentation between builds, so treat your build’s in-game docs as the final authority on method names.