blob: 88138390f8f1c709dbbc638466a71374e55e000a [file] [log] [blame] [raw]
if not os.isRobot() then
return
end
local robot = {}
-------------------------------------------------------------------------------
-- World
function robot.detect()
return component.computer.detect(sides.front)
end
function robot.detectUp()
return component.computer.detect(sides.up)
end
function robot.detectDown()
return component.computer.detect(sides.down)
end
-------------------------------------------------------------------------------
-- Inventory
function robot.select(index)
return component.computer.select(index)
end
function robot.count()
return component.computer.count()
end
function robot.space()
return component.computer.select()
end
function robot.compareTo(index)
return component.computer.compareTo(index)
end
function robot.transferTo(index, count)
return component.computer.transferTo(index, count)
end
-------------------------------------------------------------------------------
-- Inventory + World
function robot.compare()
return component.computer.compare(sides.front)
end
function robot.compareUp()
return component.computer.compare(sides.up)
end
function robot.compareDown()
return component.computer.compare(sides.down)
end
function robot.drop(count)
checkArg(1, count, "nil", "number")
return component.computer.drop(sides.front, count)
end
function robot.dropUp(count)
checkArg(1, count, "nil", "number")
return component.computer.drop(sides.up, count)
end
function robot.dropDown(count)
checkArg(1, count, "nil", "number")
return component.computer.drop(sides.down, count)
end
function robot.place(side, sneaky)
checkArg(1, side, "nil", "number")
return component.computer.place(sides.front, side, sneaky ~= nil and sneaky ~= false)
end
function robot.placeUp(side, sneaky)
checkArg(1, side, "nil", "number")
return component.computer.place(sides.up, side, sneaky ~= nil and sneaky ~= false)
end
function robot.placeDown(side, sneaky)
checkArg(1, side, "nil", "number")
return component.computer.place(sides.down, side, sneaky ~= nil and sneaky ~= false)
end
function robot.suck(count)
checkArg(1, count, "nil", "number")
return component.computer.suck(sides.front, count)
end
function robot.suckUp(count)
checkArg(1, count, "nil", "number")
return component.computer.suck(sides.up, count)
end
function robot.suckDown(count)
checkArg(1, count, "nil", "number")
return component.computer.suck(sides.down, count)
end
-------------------------------------------------------------------------------
-- Tool
function robot.durability()
return component.computer.durability()
end
function robot.swing(side)
checkArg(1, side, "nil", "number")
return component.computer.swing(sides.front, side)
end
function robot.swingUp(side)
checkArg(1, side, "nil", "number")
return component.computer.swing(sides.up, side)
end
function robot.swingDown(side)
checkArg(1, side, "nil", "number")
return component.computer.swing(sides.down, side)
end
function robot.use(side, sneaky, duration)
checkArg(1, side, "nil", "number")
checkArg(3, duration, "nil", "number")
return component.computer.use(sides.front, side, sneaky ~= nil and sneaky ~= false, duration)
end
function robot.useUp(side, sneaky, duration)
checkArg(1, side, "nil", "number")
checkArg(3, duration, "nil", "number")
return component.computer.use(sides.up, side, sneaky ~= nil and sneaky ~= false, duration)
end
function robot.useDown(side, sneaky, duration)
checkArg(1, side, "nil", "number")
checkArg(3, duration, "nil", "number")
return component.computer.use(sides.down, side, sneaky ~= nil and sneaky ~= false, duration)
end
-------------------------------------------------------------------------------
-- Movement
function robot.forward()
return component.computer.move(sides.front)
end
function robot.back()
return component.computer.move(sides.back)
end
function robot.up()
return component.computer.move(sides.up)
end
function robot.down()
return component.computer.move(sides.down)
end
function robot.turnLeft()
return component.computer.turn(false)
end
function robot.turnRight()
return component.computer.turn(true)
end
function robot.turnAround()
local turn = math.random() < 0.5 and robot.turnLeft or robot.turnRight
return turn() and turn()
end
_G.robot = robot