pirga

гук v0.1

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