Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- robot = require("robot")
- component = require("component")
- os = require("os")
- nav = component.navigation
- waitTime = 30 -- how long to wait after unloading
- function unload()
- for i = 1, 16 do
- robot.select(i)
- robot.dropUp()
- end
- robot.select(1)
- end
- function forwardFarm()
- local isMoved = false
- robot.swingDown()
- robot.placeDown()
- while isMoved ~= true do
- isMoved = robot.forward()
- end
- end
- function turnRight(dir)
- while dir ~= nav.getFacing() do
- robot.turnRight()
- end
- end
- function turnLeft(dir)
- while dir ~= nav.getFacing() do
- robot.turnLeft()
- end
- end
- function doTurn()
- local x, y, z = nav.getPosition()
- local dir = nav.getFacing()
- local temp = 0
- local face = dir
- if z == 44.5 then
- temp = math.floor(x)
- temp = temp % 2
- if temp == 1 then
- face = 4
- else
- face = 2
- end
- turnRight(face)
- elseif z == 29.5 then
- temp = math.floor(x)
- temp = temp % 2
- if x ~= -65.5 or x ~= -49.5 then
- if temp == 0 then
- face = 4
- else
- face = 3
- end
- end
- turnLeft(face)
- elseif z == 28.5 then
- if x == -65.5 then
- face = 5
- elseif x == -49.5 then
- face = 3
- end
- turnRight(face)
- end
- end
- while true do
- robot.forward()
- doTurn()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement