OpenComputers · Automation · Advanced
OpenComputers Drones and Microcontrollers Guide
In this advanced OpenComputers guide, you will learn how to write and flash custom Lua BIOS scripts directly onto EEPROM chips to run headless automation tasks using Microcontrollers and flying Drones. Mastering these lightweight devices allows you to build cheap, energy-efficient redstone controllers and rapid aerial transport units without bears the resource overhead of full computer systems.
What you need
- A working Tier 1 (or higher) Computer running OpenOS with a Hard Disk Drive, Screen, and Keyboard
- Electronic Assembler and a stable power source (from a compatible tech mod via a Power Converter if needed)
- Charger block (to power Drones)
- Blank EEPROMs and a standard EEPROM (Lua BIOS) for your main computer
- Microcontroller Case or Drone Case (Tier 1 or Tier 2)
- Low-tier CPU, minimal Memory (RAM), and task-specific components (e.g., Redstone Card, Wireless Network Card, Inventory Upgrade, or Leash Upgrade)
Step by step
1Understand the Headless Environment
Before writing code, realize that Microcontrollers and Drones cannot mount Hard Disk Drives or boot into OpenOS. Because they execute code directly from the EEPROM, standard OpenOS libraries like 'require', 'os.sleep', or 'term' do not exist. Instead, you must use the raw 'component' and 'computer' APIs provided by the underlying machine architecture.
Tip: Test your raw component calls in the standard Lua interpreter on your main computer before shrinking them for an EEPROM.
2Obtain Component Proxies in Raw Lua
Boot up your main OpenOS computer and create a new script file using 'edit bios.lua'. Because you cannot use 'require("component")', you must manually fetch the component proxy at the top of your script using the raw syntax: 'local redstone = component.proxy(component.list("redstone")())' or 'local drone = component.proxy(component.list("drone")())'. This grabs the memory address of the first matching internal component and wraps it into an accessible table of functions.
Tip: Keep variable names short if your script is complex, as EEPROMs have a strict byte size limit (typically 4 kilobytes; check JEI or the in-game manual for exact memory capacities).
3Write the Main Event Loop
A custom BIOS script must never reach the end of the file, or the device will immediately throw a 'computer halted' error and power down. Below your component definitions, create an infinite loop using 'while true do ... end'. Inside this loop, use 'local evt, addr, arg1, arg2 = computer.pullSignal(1)' to pause execution for up to one second while waiting for hardware interrupts like network messages or redstone changes.
Tip: Always include a 'computer.pullSignal()' call inside your infinite loop; without it, the script will trigger a 'too long without yielding' crash.
4Add Task Logic for Drone or Microcontroller
Inside your event loop, add your hardware instructions. For a Microcontroller with a Redstone Card, you might check 'if redstone.getInput(0) > 0 then redstone.setOutput(1, 15) end'. For a Drone with a Wireless Network Card, wait for a 'modem_message' event from 'computer.pullSignal()', parse the coordinates sent from your main base computer, and call 'drone.move(dx, dy, dz)' to fly to the target location.
Tip: Drones move relative to their current position, not by absolute world coordinates. Use a Navigation Upgrade if your Drone needs to know its exact world coordinates.
5Hot-Swap and Flash the EEPROM
Save and exit your script on the main computer. While the computer is still running in OpenOS, open the Computer Case GUI, remove the existing EEPROM (Lua BIOS), and insert a blank or overwritable EEPROM in its place. Return to the terminal screen and run 'flash -q bios.lua "Custom Controller"' to burn your script onto the inserted chip. Once finished, immediately swap your standard Lua BIOS EEPROM back into the main computer so it can reboot normally next time.
Tip: OpenOS remains loaded in RAM after booting, which is why you can safely swap out the EEPROM while the system is powered on.
6Assemble the Device
Place your Microcontroller Case or Drone Case into the central slot of the Electronic Assembler. Populate the revealed component slots with a CPU, a stick of RAM, your newly flashed EEPROM, and the specific cards or upgrades your script calls (such as a Redstone Card for the Microcontroller or an Inventory Upgrade for the Drone). Check the Assembler GUI to ensure complexity limits are respected, then click the start button and wait for fabrication to complete.
Tip: Microcontrollers and Drones cannot be disassembled easily without risking part loss, so double-check that your flashed EEPROM is inside before starting assembly.
7Power and Deploy
If you built a Microcontroller, place it in the world, connect it to a power cable, and press its power button or apply a redstone signal (depending on configuration) to start the BIOS loop. Note that Microcontrollers completely isolate their internal network from external OpenComputers cables unless you use a Wireless Network Card or pass messages appropriately. If you built a Drone, place it next to an active Charger block that is receiving a redstone signal until its internal battery is full, then shift-right-click or activate it to launch your aerial script.
Tip: Use the Status Text feature on Drones via 'drone.setStatusText("Flying")' to display tiny floating debug text on the Drone's body in-world.
How it works
In OpenComputers, every device starts by executing whatever raw Lua code is burned onto its EEPROM. On a standard computer, the default 'Lua BIOS' EEPROM searches attached filesystems for an 'init.lua' file, which subsequently loads OpenOS into RAM. Microcontrollers and Drones lack filesystem slots entirely to keep their crafting costs low and their form factors compact. By flashing your own automation script onto the EEPROM, your code becomes the BIOS itself, executing immediately upon boot with minimal RAM consumption.
Because there is no operating system acting as a middleman, you interact directly with the OpenComputers virtual machine architecture. The global 'component' table allows you to query hardware addresses using 'component.list()' and invoke hardware methods directly via 'component.invoke()' or 'component.proxy()'. Meanwhile, 'computer.pullSignal()' serves two critical purposes: it captures hardware events (like wireless packets or redstone state changes) and yields execution back to the Minecraft server thread so the mod's sandbox timer does not forcibly terminate your script for hogging CPU cycles.
Drones and Microcontrollers also handle networking and redstone differently than full Computer Cases. A Microcontroller is an enclosed unit; its internal components cannot see external components attached to adjacent cables. Instead, it interacts with the outside world strictly through sided Redstone IO or network packets. Drones operate similarly as self-contained entities, relying on internal battery reserves and asynchronous physics-based movement calls (where 'drone.move()' tells the drone to start flying toward an offset, requiring your script to poll 'drone.getOffset()' or 'drone.getVelocity()' to verify when it has actually arrived).
Common mistakes
- Rebooting the main computer before swapping the original Lua BIOS EEPROM back in. If you forget, your main computer will boot your custom Drone/Microcontroller script and crash, forcing you to craft a new Lua BIOS EEPROM using the manual crafting recipe.
- Attempting to use OpenOS functions like 'require()', 'os.sleep()', 'io.open()', or 'print()'. None of these exist at the BIOS level; use 'computer.pullSignal(seconds)' for sleeping and 'component.proxy()' for loading hardware.
- Forgetting to yield inside a 'while true' loop. If a loop runs without calling 'computer.pullSignal()' (or a synchronous component call that yields internally), the machine will halt after a few seconds with a 'too long without yielding' error.
- Connecting a Microcontroller to an Adapter or external component via cables and expecting it to show up in 'component.list()'. Microcontrollers seal their internal bus from external networks; they can only pass network messages or output redstone signals across their block faces.
- Assuming 'drone.move(x, y, z)' waits for the Drone to finish moving before running the next line of code. Drone movement is asynchronous; you must loop with 'computer.pullSignal(0.5)' while checking if 'drone.getVelocity() == 0' and 'drone.getOffset() < 0.2' before executing arrival actions like dropping items.
FAQ
How do I debug my EEPROM script if there is no screen attached to a Drone or Microcontroller?
For Drones, call 'drone.setStatusText(tostring(err))' inside a 'pcall()' wrapper to display errors right on the Drone model, or broadcast error strings over a Wireless Network Card to a listening main computer. You can also call 'computer.beep(1000, 0.2)' to use audio cues for debugging execution steps.
How can I update the code inside an already assembled Drone or Microcontroller?
Place the assembled Drone or Microcontroller into a crafting grid along with your newly flashed EEPROM. This swaps the old EEPROM out for the new one without destroying the device or needing the Electronic Assembler again.
Why isn't my Drone charging when placed next to a Charger block?
OpenComputers Chargers require both power from a power network and an active redstone signal (like a Lever placed directly on the Charger and flipped on) to begin transferring energy to adjacent Drones or Robots.
How do I shrink my script if it exceeds the EEPROM byte limit?
Remove all comments, shorten variable names, reduce indentation whitespace, and offload complex decision logic to a central server computer that sends simple command packets over a Wireless Network Card to the Drone or Microcontroller.
By writing raw component-level Lua scripts and flashing them onto EEPROMs, you can deploy self-contained Microcontrollers and flying Drones for cheap, headless automation across your base.