Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local extractor = peripheral.wrap("back")
- local storageChest = peripheral.wrap("container_chest_0")
- local function tableCount(inputTable)
- local count = 0
- for _ in pairs(inputTable) do count = count + 1 end
- return count
- end
- while true do
- print("sleeping")
- sleep(1)
- print("processing redstone") -- This takes a comparitor input (from an industrial coil) from the right,
- -- lets the extractor run if the value is 2+, forces it to run if it is
- -- 4+ (to prevent explosions) and will stop the extractor if it drops below 1
- -- It also checks to see if any actual work needs doing
- --if redstone.getAnalogInput("right") == 0 then
- -- redstone.setOutput("left",false)
- --else
- if redstone.getAnalogInput("right") > 4 then
- redstone.setOutput("left",true)
- elseif tableCount(extractor.getAllStacks()) ~= 0 --[[ and redstone.getAnalogInput("right") > 2 ]] then
- redstone.setOutput("left",true)
- else
- redstone.setOutput("left",false)
- end
- print("exporting stuffed items to chest") -- Grab items from the bottom left 3 slots of the extractor
- for i = 2,4,1 do
- print("slot "..i)
- storageChest.pullItem("west", i)
- end
- print("compressing chest")
- storageChest.condenseItems()
- print("trying to import back") -- Push items back, where they will fit
- for i,data in pairs(storageChest.getAllStacks()) do
- print("chest slot "..i)
- for j = 2,4,1 do
- print("extractor slot "..j)
- if storageChest.pushItemIntoSlot("west",i,j) > 0 then
- print("success!")
- else
- print("didn't fit")
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment