Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- ---Program to automate throwing away trash
- ---Exports listed items from drawers to chest (which should be over a chute over lava/cactus, etc)
- ---Runs with a long sleep at the end because trash isn't a high priority
- ---review IMPORTANT comments, if you don't you will trash something you didn't want to
- ---
- --By: hornedcommando
- -- Define the list of trash items IMPORTANT: Change this or risk having the wrong items thrown away
- local trashItems = {
- ["minecraft:poisonous_potato"] = true,
- ["forbidden_arcanus:golden_orchid_seeds"] = true,
- }
- -- Define the peripheral names
- local voidChest = peripheral.wrap("minecraft:chest_4") -- IMPORTANT: Change this to the void chest
- -- Function to dynamically find all connected storage drawers
- local function getConnectedDrawers()
- local drawers = {}
- for _, name in ipairs(peripheral.getNames()) do
- if peripheral.getType(name):find("storagedrawers:standard_drawers_1") then
- local drawer = peripheral.wrap(name)
- table.insert(drawers, {name = name, drawer = drawer}) -- Store both name and wrapped drawer
- end
- end
- return drawers
- end
- -- Function to move trash items from drawers to the void chest
- local function moveTrashItemsToVoidChest(drawers)
- for _, drawerInfo in ipairs(drawers) do
- local drawerContents = drawerInfo.drawer.list()
- for slot, item in pairs(drawerContents) do
- if trashItems[item.name] then
- local success = drawerInfo.drawer.pushItems(peripheral.getName(voidChest), slot, item.count)
- if success == 0 then
- print("Failed to move trash item: " .. item.name)
- else
- print("Moved " .. item.count .. " of " .. item.name .. " to void chest.")
- end
- end
- end
- end
- end
- -- Main function
- local function main()
- while true do
- local drawers = getConnectedDrawers()
- moveTrashItemsToVoidChest(drawers)
- os.sleep(120) -- The Trash man comes every 2 minutes
- end
- end
- -- Start the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement