Advertisement
Asioron

generator_kam_eeprom

Sep 14th, 2019
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. -------------------------------------------------------
  2. --     Программа: генератор укрепленного камня       --
  3. --         для роботов из мода OpenComputers         --
  4. --          проект http://computercraft.ru           --
  5. --              Version 0.1(eeprom)                  --
  6. --                 2019, © Asior                     --
  7. -------------------------------------------------------
  8. --инструмент: любой бур; 1: леса железные; 2: песок; 3: распылитель; рука: бур/кирка/ваджа
  9. --расширения: инвентарь, контроллер инвентаря
  10.  
  11. r = component.proxy(component.list("robot")())
  12. ic = component.proxy(component.list("inventory_controller")())
  13.  
  14. local function sleep(timeout)
  15.   local deadline = computer.uptime() + (timeout or 0)
  16.   repeat
  17.     computer.pullSignal(0)
  18.   until computer.uptime() >= deadline
  19. end
  20.  
  21. local function import()
  22.   if r.count(1) <= 2 or r.count(2) <= 2 then
  23.     r.select(1)
  24.     for n = 1, 2 do
  25.       if r.count(n) == 0 then
  26.         error('Нет нужных ресурсов')
  27.       end
  28.       label = ic.getStackInInternalSlot(n).label
  29.       for i=1,ic.getInventorySize(1) do
  30.         name = ic.getStackInSlot(1,i)
  31.         if name then
  32.           if name.label == label then
  33.             ic.suckFromSlot(1,i,63-r.count(n),n)
  34.             break
  35.           end
  36.         end
  37.       end
  38.     end
  39.   end
  40. end
  41.  
  42. local function refuel()
  43.   r.select(3)
  44.   r.turn(true)
  45.   ic.equip()
  46.   r.drop(3)
  47.   for i=4,16 do
  48.     if r.count(i)>0 then
  49.       r.select(i)
  50.       r.drop(0,64)
  51.     end
  52.   end
  53.   sleep(20)
  54.   r.select(3)
  55.   r.suck(3)
  56.   r.turn(false)
  57.   r.turn(false)
  58.   ic.equip()
  59.   r.drop(3)
  60.   sleep(15)
  61.   r.suck(3)
  62.   r.turn(true)
  63. end
  64.  
  65.  
  66. while true do
  67.   for i=1, 80 do
  68.     r.select(1)
  69.     r.place(3)
  70.     r.select(3)
  71.     ic.equip()
  72.     r.use(3)
  73.     r.select(2)
  74.     ic.equip()
  75.     r.use(3)
  76.     ic.equip()
  77.     r.select(3)
  78.     ic.equip()
  79.     r.swing(3)
  80.     import()
  81.   end
  82.   refuel()
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement