Bonkie

Inventory mngmnt

Nov 29th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. local aeinterface = peripheral.wrap('meBridge_1')
  2. local voidchest = peripheral.wrap('void_chest_1')
  3. local slotStart = 0
  4. local slotEnd = 26
  5. local slotTimeOut = 10
  6. local defaultamount = 50000
  7. local outputDirection = 1
  8.  
  9. function selectSlot()
  10.   while true do
  11.     for i=slotStart,slotEnd do
  12.       slotinfo = voidchest.getStackInSlot(i)
  13.       --print('Checking space in slot: '.. i)
  14.       if slotinfo == nil then
  15.         print('Slot '.. i ..' is empty.')
  16.         return i
  17.       end
  18.     end
  19.     sleep(slotTimeOut)
  20.   end
  21. end
  22.  
  23. function removeItems(id)
  24.   print('Removing item: '.. id)
  25.   selectSlot()
  26.   aeinterface.retrieve(id,64,outputDirection)
  27. end
  28.  
  29.  
  30. while true do
  31.   local aeitems = aeinterface.listAll()
  32.   if aeitems ~= nil then
  33.     for id,amount in pairs(aeitems) do
  34.       --print(id..": "..amount)
  35.       if amount>defaultamount then
  36.         sleep(0.5)
  37.         removeItems(id)
  38.       end
  39.     end
  40.   end
  41.   sleep(10)
  42. end
Advertisement
Add Comment
Please, Sign In to add comment