Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.wrap("back")
- modem.open(1)
- local source = peripheral.getNames()
- local filterChest = peripheral.wrap("top")
- local function getFilterItems()
- local filterItems = {}
- for slot, item in pairs(filterChest.list()) do
- filterItems[item.name] = true
- end
- return filterItems
- end
- while true do
- local sourceChests = {}
- local targetChests = {}
- local filterItems = getFilterItems()
- for _, name in ipairs(source) do
- if string.match(name, "ironchests:iron_") then
- table.insert(sourceChests, peripheral.wrap(name))
- elseif string.match(name, "kibe:trash_can") then
- table.insert(targetChests, peripheral.wrap(name))
- end
- end
- for _, sourceChest in ipairs(sourceChests) do
- for _, targetChest in ipairs(targetChests) do
- local targetName = peripheral.getName(targetChest)
- for slot, item in pairs(sourceChest.list()) do
- if not filterItems[item.name] then
- sourceChest.pushItems(targetName, slot)
- end
- end
- end
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement