Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- ---Program to automate the washing of items using encased fan and depot
- ---Exports washable items from Occultism storage to depot
- ---Imports washed items from depot to Occultism storage
- ---washable and washed lists can be modified to include/exclude items
- ---review IMPORTANT comments, these are configurables that will likely change based on your setup
- ---
- --By: hornedcommando
- -- Define peripherals
- local depot = peripheral.wrap("create:depot_4") -- IMPORTANT: Change this to the depot where washed items are stored
- local occultism = peripheral.wrap("occultism:storage_controller_3") -- Occultism storage controller
- -- List of washable items
- local washable = {
- ["biomesoplenty:orange_sand"] = true,
- ["biomesoplenty:white_sand"] = true,
- ["minecraft:sand"] = true,
- ["create:wheat_flour"] = true,
- ["minecraft:red_sand"] = true,
- ["minecraft:gravel"] = true,
- ["minecraft:soul_sand"] = true,
- }
- -- List of washed items
- local washedItems = {
- ["minecraft:clay_ball"] = true,
- ["minecraft:gold_nugget"] = true,
- ["minecraft:iron_nugget"] = true,
- ["minecraft:quartz"] = true,
- ["minecraft:flint"] = true,
- }
- -- Function to get the contents of the Occultism storage
- local function getStorageContents(storage)
- local contents = {}
- for slot, item in pairs(storage.list()) do
- contents[item.name] = (contents[item.name] or 0) + item.count
- end
- return contents
- end
- -- 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 depot
- local function pushItems(storage, itemName)
- for slot, item in pairs(storage.list()) do
- if item.name == itemName then
- local success = storage.pushItems(peripheral.getName(depot), 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 depot.")
- end
- end
- end
- return true -- Successfully processed all items in the storage
- end
- -- Function to process sand
- local function processSand(storage)
- print("Processing sand...")
- -- Count the items in the storage
- local clayCount = countItems(storage, "minecraft:clay_ball")
- local sandTypes = {
- "minecraft:sand",
- "biomesoplenty:white_sand",
- "biomesoplenty:orange_sand"
- }
- local highestSandCount = 0
- local suitableSandType = nil
- for _, sandType in ipairs(sandTypes) do
- local sandCount = countItems(storage, sandType)
- print("Clay count: " .. clayCount .. ", " .. sandType .. " count: " .. sandCount)
- if sandCount > highestSandCount then
- highestSandCount = sandCount
- suitableSandType = sandType
- end
- end
- if highestSandCount > clayCount then
- return pushItems(storage, suitableSandType)
- else
- print("Skipping sand processing as no suitable sand type is available.")
- return true
- end
- end
- -- Function to process red sand
- local function processRedSand(storage)
- print("Processing red sand...")
- local goldNuggetCount = countItems(storage, "minecraft:gold_nugget")
- local redSandCount = countItems(storage, "minecraft:red_sand")
- print("Gold nugget count: " .. goldNuggetCount .. ", Red sand count: " .. redSandCount)
- if goldNuggetCount > redSandCount then
- print("Skipping red sand processing as gold nugget count is greater than red sand count.")
- return true
- end
- return pushItems(storage, "minecraft:red_sand")
- end
- -- Function to process gravel
- local function processGravel(storage)
- print("Processing gravel...")
- local ironNuggetCount = countItems(storage, "minecraft:iron_nugget")
- local gravelCount = countItems(storage, "minecraft:gravel")
- print("Iron nugget count: " .. ironNuggetCount .. ", Gravel count: " .. gravelCount)
- if ironNuggetCount > gravelCount then
- print("Skipping gravel processing as iron nugget count is greater than gravel count.")
- return true
- end
- return pushItems(storage, "minecraft:gravel")
- end
- -- Function to process soul sand
- local function processSoulSand(storage)
- print("Processing soul sand...")
- local quartzCount = countItems(storage, "minecraft:quartz")
- local soulSandCount = countItems(storage, "minecraft:soul_sand")
- print("Quartz count: " .. quartzCount .. ", Soul sand count: " .. soulSandCount)
- if quartzCount > soulSandCount then
- print("Skipping soul sand processing as quartz count is greater than soul sand count.")
- return true
- end
- return pushItems(storage, "minecraft:soul_sand")
- end
- -- Function to move washed items from the depot to the Occultism storage
- local function moveWashedItemsToStorage(storage)
- local depotItems = depot.list()
- for slot, item in pairs(depotItems) do
- if washedItems[item.name] then
- local success = depot.pushItems(peripheral.getName(storage), slot, item.count)
- if success == 0 then
- print("Cannot push washed item to storage! Check storage capacity.")
- return false -- Failed push, continue checking other items
- else
- print("Moved " .. item.count .. " of " .. item.name .. " to storage.")
- end
- else
- print("Item " .. item.name .. " is not a washed item.")
- end
- end
- return true -- Successfully processed all washed items
- end
- -- Main loop function
- local function main()
- while true do
- -- Process each type of item separately
- local sandSuccess = processSand(occultism)
- local redSandSuccess = processRedSand(occultism)
- local gravelSuccess = processGravel(occultism)
- local soulSandSuccess = processSoulSand(occultism)
- os.sleep(3) -- Wait 3 seconds to allow washing to finish
- print("Moving washed items to storage...")
- moveWashedItemsToStorage(occultism)
- end
- end
- -- Start the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement