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
| Pattern | Meaning | Starter example |
|---|---|---|
get_component("name") | Fetch another machine/component by name | get_component("clock") |
self | The machine whose script slot is currently running | Solar generator calls its own tilt method |
| Variable | Keep a value for later lines | sun = clock.get_elevation() |
if / else | Choose a branch from a condition | Pressure odd/even repair |
while True | Keep a script running continuously | Solar tracker loop |
| List | Ordered values accessed by index | sites = self.scan() then sites[0] |
| Dictionary | Values stored by key | Biology 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)