Advertisement
FellHead

HarvestCraft farm OpenComputers

Apr 3rd, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. local robot = require("robot")
  2. local comp = require("computer")
  3.  
  4. -- vsya dlina polya pered robotom
  5. local vper = 10
  6. -- vsya shirina polya
  7. local shir = 5
  8.  
  9. function harvest()
  10. -- Vhod na pole
  11.   robot.forward()
  12. -- po shirine
  13.   for y=1, (shir-1) do
  14.     -- harvest one line
  15.     robot.useDown()
  16.     robot.suckDown()
  17.     for x=1, (vper-1) do
  18.       robot.forward()
  19.       robot.useDown()
  20.       robot.suckDown()
  21.     end
  22.         -- povorot
  23.         --esli y nechetnoe to
  24.     if y%2 == 1 then
  25.           robot.turnLeft()
  26.           robot.forward()
  27.           robot.turnLeft()
  28.         else
  29.           robot.turnRight()
  30.           robot.forward()
  31.           robot.turnRight()
  32.         end
  33.   end
  34.   -- na posledneij linii
  35. for x=1, (vper-1) do
  36.       robot.forward()
  37.       robot.useDown()
  38.       robot.suckDown()
  39.     end
  40.   -- vozvrat
  41.        if shir%2 == 1 then
  42.        robot.turnRight()
  43.          while robot.detect()==false do
  44.          robot.forward()
  45.          end
  46.        robot.turnRight()
  47.            while robot.detect()==false do
  48.            robot.forward()
  49.            end
  50.        else
  51.        robot.turnLeft()
  52.            while robot.detect()==false do
  53.            robot.forward()
  54.            end
  55.        robot.turnRight()
  56.        robot.forward()
  57.        end
  58. end
  59.  
  60. function unload()
  61.   for c = 1, 32 do
  62.     robot.select(c)
  63.     robot.drop()
  64.     end
  65.   end
  66.   robot.turnAround()
  67. end
  68.  
  69. while true do
  70.   harvest()
  71.   unload()
  72.   print('sleep')
  73.   -- one hour sleeping
  74.   os.sleep(3600)
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement