Advertisement
xeritt

OpenComputers Robot farmer

Sep 3rd, 2018
237
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local robot = require("robot")
  2. local comp = require("computer")
  3.  
  4. local size = 9
  5.  
  6. function harvest()
  7.   -- fly to start
  8.   robot.forward()
  9.   for y=1, size do
  10.     -- harvest one line
  11.     robot.swingDown()
  12.     robot.useDown()
  13.     robot.placeDown()
  14.     for x=1, (size-1) do
  15.       robot.forward()
  16.       robot.swingDown()
  17.       robot.useDown()
  18.       robot.placeDown()
  19.     end
  20.         -- turn
  21.     if y%2 == 1 then
  22.           robot.turnLeft()
  23.           robot.forward()
  24.           robot.turnLeft()
  25.         else
  26.           robot.turnRight()
  27.           robot.forward()
  28.           robot.turnRight()
  29.         end
  30.   end
  31.   -- return
  32.   for y=1, (size-1) do
  33.     robot.forward()
  34.   end
  35.   robot.turnLeft()
  36.   for y=1, (size) do
  37.     robot.forward()
  38.   end
  39.   robot.turnRight()
  40.   robot.forward()
  41.   robot.turnAround()
  42. end
  43.  
  44. function unload()
  45.   robot.turnAround()
  46.   for c = 2, 16 do
  47.     robot.select(c)
  48.     if robot.count() > 0 then
  49.       robot.drop()
  50.     else
  51.       robot.select(1)
  52.       break
  53.     end
  54.   end
  55.   robot.turnAround()
  56. end
  57.  
  58. while true do
  59.  harvest()
  60.   if robot.count(2) == 64 then
  61.     unload()
  62.   end
  63.  
  64.   -- one hour sleeping
  65.   for i=1, 100 do
  66.     os.sleep(36)
  67.     print((1*i)..'%')
  68.   end
  69.   --
  70. end
Advertisement
RAW Paste Data Copied
Advertisement