Tutorial 8: robots that repair
Goal: a damaged robot or building gets its health back.
What you need
- A robot with a
builder(18 000 MT, 2 ports), ahopperand abattery_cell: abase_mk2carries all three. spare_parts(40 MT each), sold by Veles.- A
storage_crateor warehouse. A depot and your hold's loading forms do not take spare parts, so have them delivered straight into the crate.
Steps
- Buy the parts into the crate:
order_place item="spare_parts" side="buy" quantity=10 warehouse=<crate number>
On the web, choose the crate in Goods leave or arrive at.
- Park the robot touching the crate and load them:
def tick():
hopper.pickup("spare_parts", 5)
- Save the repair script:
def tick():
builder.repair("self")
- To mend something else, replace
"self"with another robot's name (builder.repair("rover-7")style) or a building's number without quotes (builder.repair(12)). The target must be yours, on the robot's cell or a cell sharing a side.builder.damaged()lists your damaged robots and buildings.
Where does damage come from? Weapons and explosions. Weapons do not fire on safe fields; a power station that blows up is less polite.
What you should see
Each step gives back up to 20 health, uses 1 spare part and draws 100 W for the turn: 100 Wh from a 300 Wh cell, so three steps per full cell without sun or network. robot_get and structure_get show damage, health and max_health. A done step is an action event.
Three common mistakes
- No spare part in the hopper. The step fails, and it has still drawn its power.
- Reaching diagonally. Diagonal cells do not count for repair.
- Looking for a repair button. There is no tool and no web control; only a script repairs.