Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- ---Desc: A Composter program which automatically searches Occultism storage
- ---and moves compostable items to a destination hopper for composting.
- ---Extracts bonemeal output back into Occultism storage.
- ---Does not run if bonemeal count > fir_sapling (limiter helps balance inventory).
- ---This is an upgrade from the first iteration because it interacts with the higher tier Occultism storage
- ---Review IMPORTANT comments, these are configurables that will likely change based on your setup.
- ---
- --By: hornedcommando
- -- Define peripherals
- local compostHopper = peripheral.wrap("minecraft:hopper_4") -- IMPORTANT: Change this to the hopper on top of the composter
- local outputHopper = peripheral.wrap("minecraft:hopper_5") -- IMPORTANT: Change this to the hopper where bonemeal is output
- local occultism = peripheral.wrap("occultism:storage_controller_3") -- Occultism storage controller
- -- Check if peripherals are wrapped correctly
- if not compostHopper then
- error("Compost hopper peripheral not found!")
- end
- if not outputHopper then
- error("Output hopper peripheral not found!")
- end
- if not occultism then
- error("Occultism storage controller peripheral not found!")
- end
- -- List of specific items to find
- local specificItems = {
- ["minecraft:wheat_seeds"] = true,
- ["minecraft:beetroot_seeds"] = true,
- ["farmersdelight:cabbage_seeds"] = true,
- ["supplementaries:flax_seed"] = true,
- ["minecraft:tomato_seeds"] = true,
- ["biomesoplenty:fir_sapling"] = true
- }
- -- Function to count specific items in the Occultism storage
- local function countItems(storage, itemName)
- local count = 0
- for slot, item in pairs(storage.list()) do
- if item.name == itemName then
- count = count + item.count
- end
- end
- return count
- end
- -- Function to push items from Occultism storage to the composter hopper
- local function pushItemsFromStorage(storage)
- local boneMealCount = countItems(storage, "minecraft:bone_meal") -- IMPORTANT: Change this to adjust the limiter for different farms
- local firSaplingCount = countItems(storage, "biomesoplenty:fir_sapling") -- IMPORTANT: Change this to the ingredient you get the most of for the specific farm
- if boneMealCount > firSaplingCount then
- print("More bone meal than fir saplings. Skipping composting for 10 seconds.")
- return true -- Skip composting
- end
- for slot, item in pairs(storage.list()) do
- if specificItems[item.name] then
- local success = storage.pushItems(peripheral.getName(compostHopper), slot, item.count)
- if success == 0 then
- print("Failed to push item: " .. item.name)
- return false -- Failed push, continue checking other items
- else
- print("Pushed " .. item.count .. " of " .. item.name .. " to composter hopper.")
- end
- end
- end
- return true -- Successfully processed all items in the storage
- end
- -- Function to move bonemeal from the output hopper to the Occultism storage
- local function moveBoneMealToStorage(storage)
- local outputItems = outputHopper.list()
- for slot, item in pairs(outputItems) do
- if item.name == "minecraft:bone_meal" then
- local success = outputHopper.pushItems(peripheral.getName(storage), slot, item.count)
- if success == 0 then
- print("Cannot push bonemeal to storage! Check storage capacity.")
- return false -- Failed push, continue checking other items
- else
- print("Moved " .. item.count .. " of bonemeal to storage.")
- end
- end
- end
- return true -- Successfully processed all bonemeal items
- end
- -- Main loop function
- local function main()
- while true do
- local success = pushItemsFromStorage(occultism)
- os.sleep(30) -- Wait 30 seconds to allow composting to finish
- moveBoneMealToStorage(occultism)
- end
- end
- -- Start the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement