SHARE
TWEET

Oreberry farm OpenComputers

FellHead Apr 3rd, 2015 (edited) 222 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. -- 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.useUp()
  17.     robot.suck()
  18.     robot.suck()
  19.     for x=1, (vper-1) do
  20.       robot.forward()
  21.       robot.useDown()
  22.       robot.useUp()
  23.       robot.suck()
  24.       robot.suck()
  25.     end
  26.         -- povorot
  27.         --esli y nechetnoe to
  28.     if y%2 == 1 then
  29.           robot.turnLeft()
  30.           robot.forward()
  31.           robot.turnLeft()
  32.         else
  33.           robot.turnRight()
  34.           robot.forward()
  35.           robot.turnRight()
  36.         end
  37.   end
  38.   -- na posledneij linii
  39. for x=1, (vper-1) do
  40.       robot.forward()
  41.       robot.useDown()
  42.       robot.useUp()
  43.       robot.suck()
  44.       robot.suck()
  45.     end
  46.   -- vozvrat
  47.        if shir%2 == 1 then
  48.        robot.turnRight()
  49.          while robot.detect()==false do
  50.          robot.forward()
  51.          end
  52.        robot.turnRight()
  53.            while robot.detect()==false do
  54.            robot.forward()
  55.            end
  56.        else
  57.        robot.turnLeft()
  58.            while robot.detect()==false do
  59.            robot.forward()
  60.            end
  61.        robot.turnRight()
  62.        robot.forward()
  63.        end
  64. end
  65.  
  66. function unload()
  67.   for c = 1, 32 do
  68.     robot.select(c)
  69.     robot.drop()
  70.     end
  71.   end
  72.   robot.turnAround()
  73. end
  74.  
  75. while true do
  76.   harvest()
  77.   unload()
  78.   print('sleep')
  79.   -- one hour sleeping
  80.   os.sleep(3600)
  81. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top