This page documents the robot-specific callbacks exposed by the real robot component. These are the controls that exist only on robots, in addition to the shared agent, inventory, tank, redstone, and upgrade-specific APIs documented on other pages.
- Repository:
opencomputers - Actual Lua component name:
robot - Backing implementation:
li.cil.oc.server.component.Robot - Typical host: robot itself
- Robot movement
- Turning
- Tool durability queries
- Activity light color
Robots also inherit many other callback groups, including:
- shared agent actions such as
swing,use, andplace - internal inventory control
- external inventory interaction from upgrades
- tank-related methods
- redstone-related methods
Those are documented on their own pages to avoid duplicating the same API multiple times.
Movement directions use the usual OpenComputers robot-relative side constants.
Typical meanings:
sides.frontsides.backsides.upsides.down
Horizontal left and right movement depends on the robot's current facing.
- Syntax:
robot.getLightColor() - Returns:
number - Purpose: Returns the current activity light color as
0xRRGGBB.
- Syntax:
robot.setLightColor(value) - Parameters:
value:number: RGB color encoded as0xRRGGBB.
- Returns:
number - Purpose: Sets the activity light color and returns the applied value.
Behavior details:
- The call pauses the computer briefly.
- Syntax:
robot.durability() - Returns:
- Success:
number - Failure:
nil, "no tool equipped"ornil, "tool cannot be damaged"
- Success:
- Purpose: Reads the durability state of the currently equipped tool.
Return meaning:
- The exact numeric meaning depends on the registered durability provider for that tool.
- It is intended as a normalized durability readout for scripts, not necessarily the raw vanilla damage value.
- Syntax:
robot.move(direction) - Parameters:
direction:number: movement direction relative to the robot.
- Returns:
- Success:
true - Failure:
nil, reason
- Success:
- Purpose: Tries to move the robot by one block in the requested direction.
Possible failure reasons include:
already movingnot enough energyimpossible move- a collision reason returned by the movement/block-content checks
Behavior details:
- Movement consumes robot energy.
- If movement fails after energy was reserved, the energy is refunded.
- Failed collision-style moves trigger a short pause and particle effect.
- Syntax:
robot.turn(clockwise) - Parameters:
clockwise:boolean:trueturns right,falseturns left.
- Returns:
- Success:
true - Failure:
nil, "not enough energy"
- Success:
- Purpose: Rotates the robot in place.
Behavior details:
- Turning consumes robot energy.
- The computer pauses for the configured turn delay.
local robot = require("robot")
local sides = require("sides")
print(string.format("Light: 0x%06X", robot.getLightColor()))
robot.setLightColor(0x33CCFF)
local durability, err = robot.durability()
print("Durability:", durability, err)
local ok, why = robot.move(sides.front)
print("Move result:", ok, why)
if ok then
robot.turn(true)
endopencomputers-agentopencomputers-inventory-controlopencomputers-redstone-vanilla