From 28e72b142fc05e47b41d8546511dfbb12a844ce9 Mon Sep 17 00:00:00 2001 From: Emerson Rosen-Jones Date: Fri, 2 Jan 2026 23:37:41 -0500 Subject: [PATCH] fix: rework using up extra materials --- oregen-manager.lua | 74 +++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 50 deletions(-) diff --git a/oregen-manager.lua b/oregen-manager.lua index b026931..e926857 100644 --- a/oregen-manager.lua +++ b/oregen-manager.lua @@ -25,20 +25,19 @@ local GLOBAL_LIMS = { local LIMIT_EXCEPTIONS = {} -local CRUSHABLE = { - "create:crimsite", - "create:asurine", - "create:veridium", - "create:ochrum", -} -local WASHABLE = { -} -local MELTABLE = { - "create:crushed_raw_iron", - "create:crushed_raw_zinc", - "create:crushed_raw_gold", - "create:crushed_raw_copper", +-- if these exist, they will be used up +local PRODUCTS = { + {"create:crimsite", CRUSHER_ADDR}, + {"create:asurine", CRUSHER_ADDR}, + {"create:veridium", CRUSHER_ADDR}, + {"create:ochrum", CRUSHER_ADDR}, + {"create:crushed_raw_iron", MELTER_ADDR}, + {"create:crushed_raw_zinc", MELTER_ADDR}, + {"create:crushed_raw_gold", MELTER_ADDR}, + {"create:crushed_raw_copper", MELTER_ADDR}, } + +-- these will be crafted when needed local RECIPES = { ["minecraft:iron_nugget"] = { {"minecraft:iron_nugget", 60}, @@ -98,50 +97,25 @@ function updateModes (ticker, current_modes) end end -function cycleItems (ticker) - local crush, wash, melt - crush = function (item, amt) +function cycleItems (ticker, items) + local makeRequest + makeRequest = function (item, amt, addr) local limit = 64 + if addr = MELTER_ADDR then limit = 9 end if amt < limit then return end local request = { name = item, _requestCount = limit } - ticker.requestFiltered(CRUSHER_ADDR, request) + ticker.requestFiltered(addr, request) os.sleep(1) - return crush(item, amt - limit) + return makeRequest(item, amt - limit) end - wash = function (item, amt) - local limit = 64 - if amt < limit then return end - local request = { - name = item, - _requestCount = limit - } - ticker.requestFiltered(WASHER_ADDR, request) - os.sleep(1) - return wash(item, amt - limit) - end - melt = function (item, amt) - local limit = 9 - if amt < limit then return end - local request = { - name = item, - _requestCount = limit - } - ticker.requestFiltered(MELTER_ADDR, request) - os.sleep(1) - return melt(item, amt - limit) - end - for _, item in pairs(ticker.stock()) do - if CRUSHABLE[item.name] ~= nil then - crush(item.name, item.count) - end - if WASHABLE[item.name] ~= nil then - wash(item.name, item.count) - end - if MELTABLE[item.name] ~= nil then - melt(item.name, item.count) + for _, pair in pairs(PRODUCTS) do + local name, addr = pair[1], pair[2] + if items[name] ~= nil then + local amt = items[name] + makeRequest(name, amt, addr) end end end @@ -204,10 +178,10 @@ function run (ticker, export_storage, current_modes) os.sleep(SLEEP_T) return run (ticker, export_storage, current_modes) end - cycleItems(ticker) updateModes(ticker, current_modes) local export_amounts = getAmounts(export_storage.list) local stock_amounts = getAmounts(ticker.stock) + cycleItems(ticker, stock_amounts) for item, mode in pairs(current_modes) do -- mode[1] is mode, mode[2] is amt_extra when exporting if mode[1] == "recipe" then