Add multi-input Andesite Alloy mixer jobs

This commit is contained in:
2026-07-18 17:45:41 +02:00
parent 756957ece6
commit a349ca92f0
+58 -11
View File
@@ -1,7 +1,7 @@
-- ATM10 Create factory scheduler V1
-- Persistent jobs, dependency planning, progress-aware retries and diagnostics.
local VERSION = "1.0.2"
local VERSION = "1.1.0"
local REFRESH_SECONDS = 1
local CONFIRM_SECONDS = 6
local DRAIN_SECONDS = 60
@@ -35,13 +35,23 @@ local RECIPES = {
input = "create:andesite_alloy", inputCount = 11,
output = "create:shaft", outputCount = 66, targetCount = 64,
},
mixer_alloy = {
label = "64 ANDESITE ALLOY", station = "mixer:1", address = "mixer:1",
inputs = {
{ item = "minecraft:andesite", count = 64 },
{ item = "alltheores:zinc_nugget", count = 64 },
},
output = "create:andesite_alloy", outputCount = 64, targetCount = 64,
},
zinc_nuggets = {
label = "576 ZINC NUGGETS", planner = "zinc_nuggets",
output = "alltheores:zinc_nugget", targetCount = 576,
},
}
local ACTION_ORDER = { "crush_asurine", "strip_oak", "planks_oak", "shafts", "zinc_nuggets" }
local ACTION_ORDER = {
"crush_asurine", "strip_oak", "planks_oak", "shafts", "zinc_nuggets", "mixer_alloy",
}
local function epoch()
if os.epoch then return math.floor(os.epoch("utc") / 1000) end
@@ -282,17 +292,54 @@ end
local function dispatchNormal(job, missingOutput)
local recipe = RECIPES[job.recipeId]
if stationBusy(recipe.station, job) then job.status = "WAITING" return false end
local desiredInput
if recipe.completion == "activity" then desiredInput = recipe.inputCount
else desiredInput = math.ceil(missingOutput / (recipe.outputCount / recipe.inputCount)) end
desiredInput = math.min(desiredInput, stock[recipe.input] or 0)
if desiredInput <= 0 then failJob(job, "Kein Input: " .. prettyItemName(recipe.input)) return false end
local sent, err = request(recipe.address, recipe.input, desiredInput)
if sent <= 0 then failJob(job, "Versand fehlgeschlagen: " .. tostring(err or recipe.input)) return false end
job.inputSent, job.lastBatchInput = (job.inputSent or 0) + sent, sent
local inputPlan = {}
if recipe.inputs then
local outputCount = math.max(1, recipe.outputCount or 1)
for _, ingredient in ipairs(recipe.inputs) do
inputPlan[#inputPlan + 1] = {
item = ingredient.item,
count = math.ceil(missingOutput * ingredient.count / outputCount),
}
end
else
local desiredInput
if recipe.completion == "activity" then desiredInput = recipe.inputCount
else desiredInput = math.ceil(missingOutput / (recipe.outputCount / recipe.inputCount)) end
inputPlan[1] = { item = recipe.input, count = desiredInput }
end
-- Check the complete recipe before sending its first package. This prevents
-- a mixer basin from receiving only one half of a planned batch.
for _, ingredient in ipairs(inputPlan) do
if ingredient.count <= 0 or (stock[ingredient.item] or 0) < ingredient.count then
failJob(job, "Zu wenig Input: " .. prettyItemName(ingredient.item)
.. " (" .. formatNumber(stock[ingredient.item] or 0)
.. "/" .. formatNumber(ingredient.count) .. ")")
return false
end
end
local sentInputs = {}
for _, ingredient in ipairs(inputPlan) do
local sent, err = request(recipe.address, ingredient.item, ingredient.count)
if sent ~= ingredient.count then
failJob(job, "Teilversand " .. prettyItemName(ingredient.item)
.. ": " .. formatNumber(sent) .. "/" .. formatNumber(ingredient.count)
.. (err and (" - " .. tostring(err)) or ""))
return false
end
sentInputs[ingredient.item] = (sentInputs[ingredient.item] or 0) + sent
job.inputSent = (job.inputSent or 0) + sent
end
job.lastBatchInputs = sentInputs
job.lastBatchInput = nil
job.activeStation, job.status = recipe.station, "RUNNING"
job.phaseStartedAt, job.lastProgressAt, job.warned = epoch(), epoch(), false
logEvent("#" .. job.id .. " gestartet: " .. recipe.label .. " (" .. sent .. " Input)", colors.orange)
local inputTotal = 0
for _, count in pairs(sentInputs) do inputTotal = inputTotal + count end
logEvent("#" .. job.id .. " gestartet: " .. recipe.label .. " (" .. inputTotal .. " Input)", colors.orange)
saveState() return true
end