Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Peripheral names
- local inputChest = "quark:variant_chest_4" -- Main input chest
- local storageController = "storagedrawers:controller_0" -- Storage controller for drawers
- local fallbackChest = "minecraft:chest_1" -- Fallback chest for unrecognized items
- -- Validate peripherals
- if not peripheral.isPresent(inputChest) then
- error("Input chest not found! Check connections and name.")
- end
- if not peripheral.isPresent(storageController) then
- error("Storage controller not found! Check connections and name.")
- end
- if not peripheral.isPresent(fallbackChest) then
- error("Fallback chest not found! Check connections and name.")
- end
- -- Main sorting loop
- while true do
- local chest = peripheral.wrap(inputChest)
- local controller = peripheral.wrap(storageController)
- local items = chest.list()
- for slot, item in pairs(items) do
- local itemName = item.name
- -- Attempt to insert into the storage controller
- local moved = chest.pushItems(storageController, slot)
- if moved > 0 then
- print("Moved " .. moved .. "x " .. itemName .. " to storage drawers")
- else
- -- If failed, move to fallback chest
- moved = chest.pushItems(fallbackChest, slot)
- if moved > 0 then
- print("Moved " .. moved .. "x " .. itemName .. " to fallback chest")
- else
- print("Failed to move " .. itemName .. " anywhere")
- end
- end
- end
- sleep(5) -- Wait before checking again
- end
Advertisement
Comments
-
- Auto sorting script to sort any item placed into a chest into its respective storage bin. Works with cc tweaked and storagebins. Originally developed for plexiglass mountain.
Add Comment
Please, Sign In to add comment
Advertisement