zed_com

API

Jul 13th, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. local robot = require('robot')
  2. local c = require('component')
  3. local sides = require('sides')
  4. local API = {}
  5.  
  6. local function Time(text, n)
  7.     for i = 1, n do
  8.         os.execute("clear")
  9.         io.write(text, i)
  10.         os.sleep(1)
  11.     end
  12. end
  13.  
  14. function API.Crystal()
  15.     local t = c.tractor_beam
  16.     local red = c.redstone
  17.     local init = true
  18.     local n = 1
  19.     while true do
  20.         robot.select(n)
  21.         if robot.count() ~= 0 then
  22.             if robot.compareTo(14) or robot.compareTo(15) or robot.compareTo(16) then
  23.                 robot.dropUp()
  24.                 init = true
  25.             elseif robot.compareTo(13) then
  26.                 for i = 1, 6 do
  27.                     robot.select(i)
  28.                     robot.dropDown()
  29.                 end
  30.                 Time('Время создание: ', 10)
  31.                 t.suck()
  32.                 for i = 1, 6 do
  33.                     robot.select(i)
  34.                     robot.dropUp()
  35.                 end
  36.             else
  37.                 robot.dropDown()
  38.                 init = false
  39.             end
  40.         else
  41.             robot.select(n)
  42.             if n == 12 then n = 1 end
  43.         end
  44.     if not init then
  45.         red.setOutput(sides.back, 15)
  46.         Time("Время роста: ", 130)
  47.         t.suck()
  48.         red.setOutput(sides.back, 0)
  49.         robot.select(1)
  50.     end
  51.     Time("Время ожидания: ",20)
  52.     end
  53. end
  54.  
  55. function API.Ore()
  56.     while true do
  57.         while robot.suckDown() or robot.suckUp() do
  58.             if robot.place() then
  59.                 os.sleep(0.5)
  60.                 if robot.swing() then
  61.                     os.sleep(0.5)
  62.                     if robot.dropDown() then
  63.                         os.sleep(1)
  64.                     end
  65.                 end
  66.             end
  67.         end
  68.         Time("Время ожидания руды: ", 300)
  69.     end
  70. end
  71.  
  72. return API
Advertisement
Add Comment
Please, Sign In to add comment