OpenComputers · Setup guide · Intermediate
How to Assemble and Program OpenComputers Robots
In this guide, you will learn how to construct a modular OpenComputers Robot using the Electronics Assembler and program it in Lua to automate resource gathering. Mastering robots allows you to offload tedious tasks like branch mining and crop harvesting to persistent, self-contained machines that interact with the world just like a player.
What you need
- Electronics Assembler and a Charger (connected to a compatible power source via Power Converter if needed)
- Computer Case (Tier 2 or Tier 3 recommended for adequate upgrade slots)
- Core computer components: CPU, Memory (RAM), Graphics Card, Hard Disk Drive, EEPROM (Lua BIOS), Screen (Tier 1), and Keyboard
- Robot upgrades: Inventory Upgrade, Inventory Controller Upgrade, Chunkloader Upgrade, and Battery Upgrade
- OpenOS Floppy Disk (and a Disk Drive Upgrade or an already-installed Hard Disk Drive)
- A mining tool (such as a Diamond Pickaxe or a rechargeable modded drill) and a Chest
Step by step
1Power the Electronics Assembler
Place your Electronics Assembler and Charger adjacent to your base's power network. If you are using energy from another tech mod (such as RF or EU), place an OpenComputers Power Converter next to the machines or connect them using OpenComputers Cables. The Assembler requires a continuous stream of energy to fuse computer components into a single robot chassis.
Tip: Place a Lever directly on the Charger and flick it on; Chargers require an active redstone signal to transfer energy into adjacent robots.
2Select the Chassis and Core Components
Open the Electronics Assembler GUI and insert a Computer Case into the far-left slot. This unlocks the component grid on the right, showing slots of varying tiers (indicated by Roman numerals). Insert your CPU, Memory sticks, Graphics Card, Hard Disk Drive, and Lua BIOS EEPROM into their corresponding slots.
Tip: If you do not want to waste an upgrade slot on a Disk Drive, pre-install OpenOS onto the Hard Disk Drive using a stationary desktop computer before putting the drive into the Assembler.
3Install Screen, Keyboard, and Functional Upgrades
To program the robot directly in the field, you must include a Tier 1 Screen and a Keyboard in the Assembler slots. Next, populate the upgrade slots: add at least one Inventory Upgrade (granting the robot internal item slots), an Inventory Controller Upgrade (allowing smart interaction with external chests and equipping tools), and a Battery Upgrade to expand its internal energy buffer. If the robot will travel far from your base, add a Chunkloader Upgrade.
Tip: Watch the 'Complexity' meter in the Assembler GUI. Every component adds complexity, and if you exceed the maximum limit of your chosen Computer Case, the assembly button will remain disabled.
4Assemble and Charge the Robot
Once all required slots are filled and no warning icons remain, click the green arrow button to start assembly. The process takes several minutes depending on the total complexity of your build and the available power. When finished, retrieve the Robot item, place it in the world directly next to your powered, redstone-active Charger, and wait for its internal battery to reach 100%.
5Boot into OpenOS and Equip a Tool
Right-click the Robot to open its interface. Press the power button to boot it up; if you used a blank Hard Disk Drive, insert your OpenOS Floppy Disk into the robot's disk slot, type 'install' in the terminal, and follow the prompts to install the operating system to the hard drive, then reboot. Place your Pickaxe into the Robot's active tool slot (indicated by a tool icon in the inventory panel on the right).
Tip: Use an unbreakable or energy-based tool from another mod so your mining script does not halt prematurely when a vanilla pickaxe breaks.
6Write a Basic Tunnel Mining Script
In the command prompt, type 'edit mine.lua' to open the built-in text editor. Enter the following code to make the robot dig a 1x2 tunnel forward for 10 blocks and return: local robot = require('robot') local length = 10 for i = 1, length do robot.swing() robot.forward() robot.swingUp() end robot.turnAround() for i = 1, length do robot.forward() end robot.turnAround()
Tip: In the OpenOS editor, press Ctrl+S to save your file and Ctrl+W to exit back to the command line.
7Add Obstacle Handling and Inventory Drop-off
Falling gravel or mobs can block movement, causing 'robot.forward()' to fail and desynchronize your step counter. Re-open 'edit mine.lua' and replace 'robot.swing()' and 'robot.forward()' with a while-loop: 'while not robot.forward() do robot.swing() end'. At the very end of the script (after the robot returns and turns around), add a loop through slots 1 to 16 calling 'robot.select(slot)' and 'robot.dropDown()' to dump mined ores into a chest placed directly beneath the starting block.
Tip: You can check exact function names and parameters at any time by consulting the in-game OpenComputers Manual or typing 'man robot' in the OpenOS shell.
8Position and Execute the Program
Break the robot with a wrench or pickaxe—it retains its installed OS and files—and place it at your desired mining level with a Chest underneath it and an active Charger behind it. Open the robot's terminal, type 'mine.lua', and press Enter. The robot will execute each Lua instruction sequentially, clearing a 2-block-high corridor, returning to the charger, and depositing its haul downward.
How it works
Unlike standard stationary computers in OpenComputers, a Robot is a self-contained entity whose hardware configuration is locked upon creation in the Electronics Assembler. This architectural difference means you cannot hot-swap RAM, CPUs, or cards once the robot is built (except for designated dynamic upgrade slots called Containers, if you specifically built them into the chassis). Every physical capability the robot has—even displaying text on its own GUI—depends on internalizing components like a Screen and Keyboard during assembly.
At the software level, the 'robot' Lua API acts as a bridge between your code and simulated player actions. When you invoke 'robot.swing()', the mod checks the item in the robot's tool slot and simulates a player left-clicking the block in front of it, consuming tool durability and internal robot energy. Importantly, movement functions like 'robot.forward()' are blocking calls that return a boolean ('true' if the robot moved, 'false' plus an error string if blocked). Wrapping movement inside a conditional 'while' loop ensures the script accounts for gravity-affected blocks like sand or gravel before counting a step forward.
Furthermore, OpenComputers features full execution persistence across world saves and chunk unloads. The Lua virtual machine state is serialized directly to disk when the chunk unloads. However, if a robot drives itself out of loaded chunks, it will freeze at the chunk boundary until a player approaches—unless a Chunkloader Upgrade is installed and activated via 'component.chunkloader.setActive(true)', which forces the server to keep the robot's current chunk ticking.
Common mistakes
- Forgetting the Screen or Keyboard during assembly: Without a Screen and Keyboard soldered into the chassis, the robot will have no terminal display, making it impossible to type commands unless you pre-programmed a headless network script onto the hard drive.
- Not including an Inventory Upgrade: By default, a newly assembled robot has zero internal inventory slots. It will break blocks with its tool, but the drops will simply fall on the ground instead of being collected.
- Assuming 'robot.forward()' always succeeds: If a bat flies in front of the robot or gravel falls into the space it just dug, a simple 'robot.forward()' call will fail silently, causing the robot to miscalculate its position and fail to return to its charger.
- Running out of power mid-tunnel: Moving, swinging tools, and simply keeping the CPU running all drain internal energy. Always add a Battery Upgrade for longer tasks and return the robot to an active Charger between runs.
FAQ
Can I add or swap components after the Robot is assembled?
No, once the Electronics Assembler finishes building a Robot, its core components are permanently locked in. However, if you include Card Containers or Upgrade Containers during assembly, you can freely swap items inside those specific container slots later.
How do I adapt the mining script for automated farming?
Replace the Pickaxe with a Hoe or leave the tool slot empty, and use 'robot.useDown()' instead of 'robot.swing()'. The 'use' function simulates a right-click, which automatically harvests mature crops or plants seeds from the currently selected inventory slot.
Why isn't my Charger powering my Robot?
The Charger block requires an active Redstone signal to function. Place a Lever directly on the Charger and switch it on, or run a redstone signal into it; you will see particle effects when it is actively charging an adjacent robot.
How do I let my Robot use tools that require modded energy (like RF or EU)?
Place a Charger next to the robot's resting spot and install an Inventory Controller Upgrade. Your script can use 'robot.equip()' to swap the depleted tool into its inventory, drop it into an adjacent modded energetic infuser or charger, wait a few seconds, suck it back up, and re-equip it.
By carefully balancing chassis complexity in the Electronics Assembler and writing resilient Lua loops with the robot API, you can deploy autonomous OpenComputers robots to handle mining, harvesting, and world interaction tasks reliably.