fix: rework using up extra materials
This commit is contained in:
parent
e4e7878987
commit
28e72b142f
1 changed files with 24 additions and 50 deletions
|
|
@ -25,20 +25,19 @@ local GLOBAL_LIMS = {
|
||||||
|
|
||||||
local LIMIT_EXCEPTIONS = {}
|
local LIMIT_EXCEPTIONS = {}
|
||||||
|
|
||||||
local CRUSHABLE = {
|
-- if these exist, they will be used up
|
||||||
"create:crimsite",
|
local PRODUCTS = {
|
||||||
"create:asurine",
|
{"create:crimsite", CRUSHER_ADDR},
|
||||||
"create:veridium",
|
{"create:asurine", CRUSHER_ADDR},
|
||||||
"create:ochrum",
|
{"create:veridium", CRUSHER_ADDR},
|
||||||
}
|
{"create:ochrum", CRUSHER_ADDR},
|
||||||
local WASHABLE = {
|
{"create:crushed_raw_iron", MELTER_ADDR},
|
||||||
}
|
{"create:crushed_raw_zinc", MELTER_ADDR},
|
||||||
local MELTABLE = {
|
{"create:crushed_raw_gold", MELTER_ADDR},
|
||||||
"create:crushed_raw_iron",
|
{"create:crushed_raw_copper", MELTER_ADDR},
|
||||||
"create:crushed_raw_zinc",
|
|
||||||
"create:crushed_raw_gold",
|
|
||||||
"create:crushed_raw_copper",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- these will be crafted when needed
|
||||||
local RECIPES = {
|
local RECIPES = {
|
||||||
["minecraft:iron_nugget"] = {
|
["minecraft:iron_nugget"] = {
|
||||||
{"minecraft:iron_nugget", 60},
|
{"minecraft:iron_nugget", 60},
|
||||||
|
|
@ -98,50 +97,25 @@ function updateModes (ticker, current_modes)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function cycleItems (ticker)
|
function cycleItems (ticker, items)
|
||||||
local crush, wash, melt
|
local makeRequest
|
||||||
crush = function (item, amt)
|
makeRequest = function (item, amt, addr)
|
||||||
local limit = 64
|
local limit = 64
|
||||||
|
if addr = MELTER_ADDR then limit = 9 end
|
||||||
if amt < limit then return end
|
if amt < limit then return end
|
||||||
local request = {
|
local request = {
|
||||||
name = item,
|
name = item,
|
||||||
_requestCount = limit
|
_requestCount = limit
|
||||||
}
|
}
|
||||||
ticker.requestFiltered(CRUSHER_ADDR, request)
|
ticker.requestFiltered(addr, request)
|
||||||
os.sleep(1)
|
os.sleep(1)
|
||||||
return crush(item, amt - limit)
|
return makeRequest(item, amt - limit)
|
||||||
end
|
end
|
||||||
wash = function (item, amt)
|
for _, pair in pairs(PRODUCTS) do
|
||||||
local limit = 64
|
local name, addr = pair[1], pair[2]
|
||||||
if amt < limit then return end
|
if items[name] ~= nil then
|
||||||
local request = {
|
local amt = items[name]
|
||||||
name = item,
|
makeRequest(name, amt, addr)
|
||||||
_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)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -204,10 +178,10 @@ function run (ticker, export_storage, current_modes)
|
||||||
os.sleep(SLEEP_T)
|
os.sleep(SLEEP_T)
|
||||||
return run (ticker, export_storage, current_modes)
|
return run (ticker, export_storage, current_modes)
|
||||||
end
|
end
|
||||||
cycleItems(ticker)
|
|
||||||
updateModes(ticker, current_modes)
|
updateModes(ticker, current_modes)
|
||||||
local export_amounts = getAmounts(export_storage.list)
|
local export_amounts = getAmounts(export_storage.list)
|
||||||
local stock_amounts = getAmounts(ticker.stock)
|
local stock_amounts = getAmounts(ticker.stock)
|
||||||
|
cycleItems(ticker, stock_amounts)
|
||||||
for item, mode in pairs(current_modes) do
|
for item, mode in pairs(current_modes) do
|
||||||
-- mode[1] is mode, mode[2] is amt_extra when exporting
|
-- mode[1] is mode, mode[2] is amt_extra when exporting
|
||||||
if mode[1] == "recipe" then
|
if mode[1] == "recipe" then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue