Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local term = require("term")
- local cyclesRun = 0
- function moveForward()
- while not (robot.forward()) do
- os.sleep(1)
- end
- end
- function pickMove()
- robot.useDown()
- moveForward()
- end
- function farmRow()
- for i=1, 8 do
- pickMove()
- end
- robot.useDown()
- end
- function nextRow(row)
- if row % 2 == 1 then
- robot.turnLeft()
- moveForward()
- robot.turnLeft()
- else
- robot.turnRight()
- moveForward()
- robot.turnRight()
- end
- end
- function farmPatch()
- for i = 1, 7 do
- farmRow()
- nextRow(i)
- end
- end
- function moveHome()
- for i = 1, 9 do
- moveForward()
- end
- robot.turnLeft()
- for i = 1, 7 do
- moveForward()
- end
- end
- function dumpItems()
- for i = 1, 16 do
- robot.select(i)
- robot.drop()
- end
- robot.select(1)
- end
- function farm()
- cyclesRun = cyclesRun + 1
- updateScreen()
- moveForward()
- farmPatch()
- moveHome()
- robot.turnRight()
- dumpItems()
- robot.turnAround()
- end
- function updateScreen()
- term.clear()
- term.setCursor(1,1)
- term.write("Running cycle " .. cyclesRun)
- end
- while true do
- farm()
- os.sleep(300)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement