This API wraps the functionality of the component robot to allow more intuitive interaction with the robot.
While the component robot has more generic functions like move([side: number])
or drop([side: number])
, this API has more intuitive and failsafe functions like turnRight
, dropDown
, forward
. Which one you use is up to you, you can even use both at the same time. Certain functions behave the same way regardless of how it's called, i.e. component.robot.name()
and robot.name()
return the same thing. Other functions behave slightly differently, i.e. robot.place()
is the equivalent of component.robot.place(sides.front)
. The following page will summarize only the additional functions provided by the API.
Note that a Robot is an OpenComputer like any other with just an additional robot component included, so the normal APIs are available as usual.
See Robot Block for additional information on the actual Robot.
The Robot's GUI displays the slots of a robot aligned from top-left to bottom-right. So for example the slot at index 1 is displayed in the top-left corner, the slot at index 2 is the next to the right and the first slot on the 2nd row is index 5.
How many slots a robot has available depends on it's setup. If a slot is specified in a function that exceeds the amount of slots a robot has available an error is thrown.
Callbacks:
robot.detectUp(): boolean, string
robot.detect()
except that it scans the block directly above the robot.robot.detectDown(): boolean, string
robot.detect()
except that it scans the block directly below the robot.robot.compareUp(): boolean
robot.compare
just for the block directly above the robot.robot.compareDown(): boolean
robot.compare
just for the block directly below the robot.robot.dropUp(): boolean
robot.drop
just for the block directly above the robot.robot.dropDown(): boolean
robot.drop
just for the block directly below the robot.robot.suckUp([count: number]): boolean
robot.suck
except that it tries to pick up items from directly above the robot.robot.suckDown([count: number]): boolean
robot.suck
except that it tries to pick up items from directly below the robot.robot.placeUp([side: number[, sneaky: boolean]]): boolean[, string]
robot.place
except that the robot tries to place the item into the space directly above it.robot.placeDown([side: number[, sneaky: boolean]]): boolean[, string]
robot.place
except that the robot tries to place the item into the space directly below it.robot.swingUp([side: number]): boolean[, string]
robot.swing
except that the block or entity directly above the robot will be the target.robot.swingDown([side: number]): boolean[, string]
robot.swing
except that the block or entity directly below the robot will be the target.robot.useUp([side: number[, sneaky: boolean[, duration: number]]]): boolean[, string]
robot.use
except that the item is used aiming at the area above the robot.robot.useDown([side: number[, sneaky: boolean[, duration: number]]]): boolean[, string]
robot.use
except that the item is used aiming at the area below the robot.robot.forward(): boolean[, string]
true
if the robot successfully moved, nil
otherwise. If movement fails a secondary result will be returned describing why it failed, which will either be 'impossible move', 'not enough energy' or the description of the obstacle as robot.detect
would return.robot.back(): boolean[, string]
robot.forward()
except that the robot tries to move backward.robot.up(): boolean[, string]
robot.forward()
except that the robot tries to move upwards.robot.down(): boolean[, string]
robot.forward()
except that the robot tries to move downwards.robot.turnLeft()
robot.turnRight()
robot.turnLeft
except that the robot turns 90° to the right.robot.turnAround()
robot.turnRight()
twice.robot.level(): number
component.experience.level()
instead (only available if the experience upgrade is installed).1.5
, then the robot is level one, and 50% towards achieving level two.robot.compareFluidUp():boolean
compareFluid
, but operates on the block above the robot.robot.compareFluidDown():boolean
compareFluid
, but operates on the block below the robot.robot.drainUp([count:number]):boolean
drain
, but operates on the block above the robot.robot.drainDown([count:number]):boolean
drain
, but operates on the block below the robot.robot.fillUp([count:number]):boolean
fill
, but operates on the block above the robot.robot.fillDown([count:number]):boolean
fill
, but operates on the block below the robot.