Advertisement
informator

Untitled

Dec 12th, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. local robot = require("robot")
  2. local comp = require("computer")
  3.  
  4.  io.write("Длина:")
  5.  local a = io.read()
  6.  io.write("Ширина:")
  7.  local b = io.read()
  8.  io.write("Слоты:")
  9.  local d = io.read()
  10.  io.write("Промежутки между сбором:")
  11.  local n = io.read()
  12.  n = tonumber(n)
  13.  
  14.  
  15.  
  16. function harvest()  
  17.   for y=1, (b-1) do
  18.     robot.useDown()
  19.     for x=1, (a-1) do
  20.       robot.forward()
  21.       robot.useDown()
  22.     end
  23.         -- разворот-------------------
  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.  
  35.   -- возврат-----------------------
  36.   if b%2 == 0 then
  37.    for y=1, (a-1) do
  38.      robot.useDown()
  39.      robot.forward()
  40.      robot.useDown()
  41.    end
  42.    robot.turnLeft()
  43.    for x=1, (b-1) do
  44.     robot.forward()
  45.    end
  46.   else
  47.     for y=1, (a-1) do
  48.       robot.useDown()
  49.       robot.forward()
  50.       robot.useDown()
  51.     end
  52.    
  53.     robot.turnRight()
  54.    
  55.     for y=1, (b-1) do
  56.       robot.forward()
  57.     end
  58.     robot.turnRight()
  59.     for y=1, (a-1) do
  60.       robot.forward()
  61.     end
  62.     robot.turnLeft()
  63.   end
  64. end
  65.  
  66. ----функция разгрузки в сундук--
  67. function unload()
  68.   robot.turnRight()
  69.   robot.select(chest)
  70.    for z=1, d do
  71.     robot.select(z)
  72.     robot.drop(64)
  73.    end
  74.   robot.turnAround()
  75. end
  76.  
  77. ----функция сна после завершения цикла--
  78. while true do
  79.   -- one hour sleeping
  80.   for i=1, 1 do
  81.     os.sleep(n)
  82.   print("Готовность:")  
  83.   print((10*i)..'%')
  84.   end
  85.  
  86. ----выполнение-------------------
  87.   harvest()
  88.   unload()
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement