Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Original: http://pastebin.com/4HwCLB6m
- local exportChest = peripheral.wrap("top")
- local enderChest = peripheral.wrap("bottom")
- local startingImportSlot = 1
- local endingImportSlot = 18
- local startingExportSlot = 19
- local endingExportSlot = 25
- function findExportSlot()
- local stacks = enderChest.getAllStacks()
- for i = startingExportSlot,endingExportSlot do
- if stacks[i] == nil then
- return i
- end
- end
- return nil
- end
- function waitForExportSlot()
- local slot = findExportSlot()
- while slot == nil do
- slot = findExportSlot()
- os.sleep(1)
- end
- return slot
- end
- function exportStack(i, stack)
- local slot = waitForExportSlot()
- print("Found slot ", slot)
- exportChest.pushItem("down", i, 64, 1)
- os.sleep(.125)
- enderChest.pullItem("up", 1, 64, slot)
- end
- function checkExports()
- local stacks = exportChest.getAllStacks()
- for i = 1,exportChest.getInventorySize() do
- local stack = stacks[i]
- if stack then
- exportStack(i, stack)
- end
- end
- end
- function watchExports()
- while true do
- checkExports()
- os.sleep(.5)
- end
- end
- function checkImports()
- local stacks = enderChest.getAllStacks()
- for i = startingImportSlot, endingImportSlot do
- if stacks[i] then
- enderChest.pushItem("south", i, 64, 1)
- os.sleep(.1)
- end
- end
- end
- function watchImports()
- while true do
- checkImports()
- os.sleep(.5)
- end
- end
- os.sleep(3)
- parallel.waitForAny(
- watchImports,
- watchExports
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement