Advertisement
serafim7

harvest [OpenComputers]

Jul 26th, 2016
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | None | 0 0
  1. --[[OpenComputers harvester create serafim  http://pastebin.com/jgZNcxZp
  2. в 1 и 2 слот ложим семена пшеници
  3. ставим над сундуком, даем роботу мотыгу
  4. требования:робот 1-го уровня, инвентарь
  5. ]]--
  6.  
  7. local com = require('component')
  8.  
  9. local lenght = 23   --длинна грядки
  10. local quantity = 9  --количество грядок
  11. local comeback = 26 --возврат к старту
  12.  
  13. if not com.isAvailable("robot") then
  14.   print("только роботы могут использовать эту программу")
  15.   os.sleep(5)
  16.   return
  17. end
  18. local r = require("robot")
  19.  
  20. local function forwardEx()
  21.   if not r.forward() then
  22.     forwardEx()
  23.   end
  24. end
  25.  
  26. local function line()
  27.   for i = 1, lenght do
  28.     if (r.count(1) > 1) then
  29.       r.select(1)
  30.     else
  31.       r.select(2)
  32.     end
  33.   r.swingDown()
  34.   r.useDown()
  35.   r.placeDown()
  36.     if i ~= lenght then
  37.        forwardEx()
  38.     end
  39.   end
  40. end
  41.  
  42. local function harvest()
  43.   print("собираю урожай")
  44.   r.turnRight()
  45.   r.turnRight()
  46.     for i = 1, quantity do
  47.       forwardEx()
  48.       r.turnLeft()
  49.       line()
  50.       r.turnRight()
  51.       forwardEx()
  52.       r.turnRight()
  53.       line()
  54.         if i ~= quantity then
  55.           r.turnLeft()
  56.           forwardEx()
  57.         end
  58.     end
  59.   r.turnRight()
  60.     for i = 1, comeback do
  61.       forwardEx()
  62.     end
  63.       for i = 3,16 do
  64.         r.select(i)
  65.         r.dropDown()
  66.       end  
  67.   r.select(1)
  68. end
  69.  
  70. while true do
  71.   harvest()
  72.   print("спим час пока пшеница вырастит")
  73.     for i = 1, 10 do
  74.       os.sleep(360)
  75.       print((10*i)..'%')
  76.     end
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement