Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local computer, component = computer or require"computer", component or require"component"
- print = print or function()end
- while not component.list("database")() do computer.beep(600,0.4) computer.pullSignal(6) print("Отсутствует база данных") end
- local inv = component.proxy(component.list("inventory_controller")())
- local db = component.proxy(component.list("database")())
- local r = component.proxy(component.list("robot")())
- local maxSlot = inv.getInventorySize(1) or 1
- local maxSlotRobot = 1
- pcall( function() local i = 0 while true do i = i + 1 r.count(i*16) maxSlotRobot = i*16 end end )
- function poisc(item)
- for i = 1, maxSlotRobot do
- if r.count(i) > 0 and item == inv.getStackInInternalSlot(i).name then
- r.select(i)
- return true
- end
- end
- end
- function itemsChest()
- local items = {}
- for j = 1, maxSlot do
- local slot = inv.getStackInSlot(1,j)
- if slot then
- if not items[slot.name] then items[slot.name] = {} end
- table.insert(items[slot.name], j)
- end
- end
- return items
- end
- local slots = itemsChest()
- for i = 1, maxSlotRobot do -- Защита, от случайной загрузки предмета (если в выделеном слоте лежит предмет)
- if r.count(i) == 0 then
- r.select(i)
- break
- end
- end
- r.drop(1)
- local size = inv.getInventorySize(3)-4 -- Размер реактора. ( -4 , потому что есть скрытые слоты по углам )
- for i = 1, size do
- if not inv.getStackInSlot(3,i) then
- local itemDB = db.get( i + ( math.ceil( i / (size/6) ) - 1 ) * ( 9 - (size/6) ) ) -- для случая если слоты реактора не совпадают со слотами бд
- if itemDB then
- repeat
- local item = slots[itemDB.name]
- if item and #item ~= 0 and inv.suckFromSlot(1,item[#item]) then
- item[#item] = nil
- break
- else
- if maxSlotRobot and poisc(itemDB.name) then break end
- print(itemDB.label.." не найден")
- computer.pullSignal(1)
- computer.beep(800,0.4)
- slots = itemsChest()
- end
- until false
- end
- inv.dropIntoSlot(3,i)
- end
- end
- r.select(1)
- print(" Mission Completed! \n respect +")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement