Python-like automation scripts for your factory. Press ▶ Run to execute manually, or enable Auto to run every 10 seconds.
Scripts use a Python-like syntax. Indentation is significant. Comments start with #.
| Construct | Example |
|---|---|
| Assignment | x = 10 |
| Augmented assignment | x += 5 · x -= 1 · x *= 2 · x /= 4 |
| If / elif / else | if x > 0: / elif x == 0: / else: |
| While loop | while IRON_ORE < 1000: |
| For loop | for i in range(5): |
| range() | range(n) · range(a, b) · range(a, b, step) |
| Boolean ops | and · or · not |
| Comparison | == != < > <= >= |
| Arithmetic | + - * / // % ** |
| Literals | True · False · None · numbers · strings |
| Control | break · continue · pass |
| Command | Description |
|---|---|
place(type, arg, n=1, module=null) |
Queue n buildings of type. arg is the resource (miners) or recipe (assembly/furnace). Costs are deducted from inventory immediately. Optional 4th argument fills all module slots with the given module type (e.g. speed_module_3); modules are consumed from inventory. |
craft(item, n=1) |
NEW Add n copies of item to the manual craft queue. Items craft one at a time in order. |
research("name") |
Start researching a technology. Pass the display name, key, or colon-separated infinite tech key. Silently ignored if already researched. |
fortify(type, n=1) |
NEW Add n walls or turrets to the perimeter. Deducts from inventory. Types: walls, gun, laser. |
limit(type, n) |
NEW Set the inventory output limit for all buildings of type to n. Example: limit("am2", 200) stops all AM2s once the output item reaches 200. |
limit(type, recipe, n) |
Set the limit for a specific building+recipe pair. Example: limit("assembly", "iron_gear", 500). |
print(value, ...) |
Log a value to the script output panel. Multiple arguments are joined with a space. |
Loading…
Loading…
Recipes are auto-generated from data/recipes.js. Adding a new recipe there automatically creates a usable script alias.
The canonical alias is the snake_case version of the recipe key. Extra shorthand aliases are listed alongside.
Loading from PLAYER_RECIPES…
The optional 4th argument fills all module slots of each placed building with the specified module. Modules are consumed from inventory at placement time. Buildings with no module slots (AM1, stone/steel furnace) ignore this argument.
Loading…
place(am3, iron_gear, 5, speed_module_3) — places 5 AM3s (4 slots each) and consumes 20 Speed Module 3 from inventory.
craft(item, n) adds n copies to the unified manual craft queue. Items are crafted one at a time in order; ingredients are consumed when crafting begins.
Loading from PLAYER_RECIPES…
fortify(type, n) transfers items from inventory to the perimeter. Will not exceed perimeter capacity.
Loading…
Pass the exact display name or internal key. Infinite techs use the colon format.
| Argument | Technology | Notes |
|---|---|---|
"automation" | Automation | Prerequisites: none |
"logistics" | Logistics | |
"steelProcessing" | Steel Processing | |
"electricMiningDrill" | Electric Mining Drill | |
"oilProcessing" | Oil Processing | |
"advancedOilProcessing" | Advanced Oil Processing | |
"plastics" | Plastics | |
"sulfurProcessing" | Sulfur Processing | |
"batteryTech" | Battery | |
"lubricant" | Lubricant | |
"flammables" | Flammables | |
"rocketFuelTech" | Rocket Fuel | |
"robotics" | Robotics | |
"constructionRobots" | Construction Robots | |
"gunTurret" | Gun Turret | |
"laserTurretTech" | Laser Turret | |
"nuclearPower" | Nuclear Power | |
"kovarex" | Kovarex Enrichment | |
"rocketSiloTech" | Rocket Silo | |
| Infinite Technologies (repeatable) | ||
"robot:speed" | Worker Robot Speed (infinite) | ∞ requires Robotics |
"robot:cargo" | Worker Robot Cargo Size (infinite, max 3) | ∞ requires Robotics |
"mining:productivity" | Mining Productivity (infinite) | ∞ requires Electric Mining Drill |
"gun:damage" | Physical Projectile Damage (infinite) | ∞ requires Gun Turret |
"laser:damage" | Laser Weapons Damage (infinite) | ∞ requires Laser Turret |
research("Automation"), research("Nuclear Power"), etc.All item counts are floored to integers. The variable name is the camelCase item key converted to SCREAMING_SNAKE_CASE.
| Variable | Item |
|---|---|
| Loading from ITEMS… | |
Every inventory variable has a corresponding DELTA_* version that shows the rate of change per second (updated every 1 second). Negative values mean consumption.
| Variable | Meaning |
|---|---|
| Loading from ITEMS… | |
Loading…
These variables count how many of each placeable building item you have in your inventory.
Use them to check whether you have buildings ready to place before calling place().
The INV_ prefix distinguishes them from placed building counts (e.g. ASSEMBLERS).
| Variable | Description |
|---|---|
| Loading from BUILDING_DEFS_DOCS… | |
ELECTRIC_MINER, BURNER_MINER,
STONE_FURNACE, ELEC_FURNACE, LAB_ITEM, BOILER_ITEM,
STEAM_ENGINE_ITEM, SOLAR_PANEL_ITEM, ACCUMULATOR_ITEM,
RADAR_ITEM, PUMPJACK_ITEM, OIL_REFINERY_ITEM,
CHEM_PLANT_ITEM, CENTRIFUGE_ITEM, ROCKET_SILO_ITEM,
GUN_TURRET_ITEM, LASER_TURRET_ITEM.
Count of each module type currently in your inventory (not installed in buildings).
Use these to gate place() calls that require modules.
The calculator's generated scripts use these automatically when a module type is selected.
Loading…
place(am3, iron_gear, 5, speed_module_3) — places 5 AM3s and fills each of their 4 module slots with Speed Module 3 (consuming 20 modules from inventory).
| Variable | Meaning |
|---|---|
POWER_GEN | Total power generation in kW |
POWER_DEMAND | Total power demand in kW |
POWER_RATIO | Generation ÷ demand (1.0 = full power) |
ACCUMULATOR_CHARGE | Stored energy in kJ |
ACCUMULATOR_MAX | Maximum accumulator capacity in kJ |
WATER | Stored water (units) |
STEAM | Stored steam (units) |
| Variable | Meaning |
|---|---|
BITER_WAVE | Current wave number (last wave that attacked) |
BITER_TIMER | Seconds elapsed since last wave (resets at 120) |
PERIMETER_SIDE | Perimeter side length in tiles |
PERIMETER_TILES | Total perimeter tiles (4 × side length) |
PERIMETER_WALLS | Stone walls currently placed |
PERIMETER_MAX_WALLS | Maximum walls the perimeter can hold |
PERIMETER_GUN_TURRETS | Gun turrets placed |
PERIMETER_LASER_TURRETS | Laser turrets placed |
PERIMETER_MAX_TURRETS | Maximum turrets (gun + laser combined) |
| Variable | Meaning |
|---|---|
Q_len | Total items in the manual craft queue (including active item) |
Q_miners | Miners / electric drills waiting in the placement queue |
Variables whose names start with MEM_ are automatically saved to the game state and persist between script executions (including Auto runs). Use them to track state across runs.
MEM_A through MEM_Z, or descriptive names like MEM_LAST_WAVE or MEM_IRON_GOAL. Values are numbers or strings.
# Count how many times this script has run MEM_RUNS = MEM_RUNS + 1 print("Run #", MEM_RUNS) # Remember when we last needed iron if IRON_ORE < 500: MEM_IRON_LOW_WAVE = BITER_WAVE place("miner", "iron")
| Function | Description |
|---|---|
floor(x) | Round down to integer |
ceil(x) | Round up to integer |
round(x) | Round to nearest integer |
abs(x) | Absolute value |
min(a, b) | Smaller of two values |
max(a, b) | Larger of two values |
sqrt(x) | Square root |
pow(base, exp) | Exponentiation |
range(n) | List 0 … n−1 |
range(a, b) | List a … b−1 |
range(a, b, step) | List with custom step |
Keep coal stocked and iron miners running
# Auto script — runs every 10 seconds if COAL < 200: place("miner", "coal") if MINERS_IRON < 5 and Q_miners == 0: place("miner", "iron", 5 - MINERS_IRON)
Research chain automation
# Unlock automation path automatically if RED_SCIENCE > 100: research("automation") if GREEN_SCIENCE > 50: research("logistics") research("robot:speed") # queues infinite tech
Defend with walls and turrets
# Fill perimeter walls first, then add gun turrets walls_needed = PERIMETER_MAX_WALLS - PERIMETER_WALLS if walls_needed > 0 and STONE_WALL >= walls_needed: fortify("walls", walls_needed) turrets_free = PERIMETER_MAX_TURRETS - PERIMETER_GUN_TURRETS - PERIMETER_LASER_TURRETS if turrets_free > 0 and GUN_TURRET_ITEM > 0: fortify("gun", turrets_free)
Persistent crafting tracker
# Craft 10 circuits, but only if queue is empty if Q_len == 0: craft("circuit", 10) MEM_CRAFT_RUNS = MEM_CRAFT_RUNS + 1 print("Craft batch", MEM_CRAFT_RUNS) else: print("Queue busy:", Q_len, "items")
Scale mining to demand
# If iron is dropping, add a miner if DELTA_IRON_ORE < 0 and IRON_ORE < 2000: place("e_drill", "iron") print("Added electric miner — iron rate:", DELTA_IRON_ORE)
Power shortage response
if POWER_RATIO < 0.8: print("Low power!", round(POWER_RATIO * 100), "%") if SOLAR_PANEL_ITEM > 0: place("solar_panel") elif STEAM_ENGINE_ITEM > 0: place("steam_engine")