Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Original: http://pastebin.com/4HwCLB6m
- This is used with a construct consisting of a vertical stack of
- * some chest (I used wood/copper, it does not have to be big)
- * a turtle (with this code)
- * ender chest, bound to a pouch
- Followed by these items to the NORTH!
- logistics remote order pipe (next to chest)
- logistics provider pipe (next to turtle)
- me interface (next to Ender Chest)
- Bind your remote orderer to the remote order pipe,
- The turtle monitors the ranges of import and export slots specified,
- importing items it finds in the Import range into the ME and pushing
- items from the chest into the export slots if one is open.
- ]]
- local exportChest = peripheral.wrap("top")
- local enderChest = peripheral.wrap("bottom")
- local startingImportSlot = 1
- local endingImportSlot = 18
- local startingExportSlot = 19
- local endingExportSlot = 27
- 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("north", i, 64, 1)
- os.sleep(.1)
- end
- end
- end
- function watchImports()
- while true do
- checkImports()
- os.sleep(.5)
- end
- end
- parallel.waitForAny(
- watchImports,
- watchExports
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement