Damaged

Extractor Optimize 2

Sep 8th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local extractor = peripheral.wrap("back")
  2. local storageChest = peripheral.wrap("container_chest_1")
  3.  
  4. local function tableCount(inputTable)
  5.    local count = 0
  6.    for _ in pairs(inputTable) do count = count + 1 end
  7.    return count
  8. end
  9.  
  10. while true do
  11.    print("sleeping")
  12.    sleep(1)
  13.    print("exporting stuffed items to chest")
  14.    storageChest.pullItem("west", 2)
  15.    storageChest.pullItem("east", 4)
  16.    storageChest.pullItem("west", 2)
  17.    storageChest.pullItem("east", 4)
  18.    print("compressing chest")
  19.    storageChest.condenseItems()
  20.    print("trying to import back") -- Push items back, where they will fit
  21.    for i,data in pairs(storageChest.getAllStacks()) do
  22.       print("chest slot "..i)
  23.       for j = 2,4,1 do
  24.          print("extractor slot "..j)
  25.          if j == 4 then
  26.             storageChest.pushItemIntoSlot("west",i,j)
  27.          else
  28.             storageChest.pushItemIntoSlot("east",i,j)
  29.          end
  30.       end
  31.    end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment