From 090fec482ac77aef53d1caa45b773dfb816267de Mon Sep 17 00:00:00 2001 From: Dystroyer8 Date: Sat, 18 Jul 2026 21:37:39 +0200 Subject: [PATCH] Synchronize dependency output handoff --- README.md | 5 +++++ create_factory_scheduler.lua | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 535c34b..8493337 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ verwenden in ATM10 `alltheores:gold_plate`. Ihre lokalen Deployer-, Chute- und Vault-Puffer werden durch Factory Gauges versorgt; der globale Keep-Stock fuellt verbrauchte Cogwheels und Iron Nuggets parallel wieder auf. +V1.3.2 synchronisiert Vorauftrag und Hauptauftrag explizit: Das erzeugte Material +wird erst freigegeben, nachdem der Vorauftrag seine Ankunft registriert hat. So +kann ein nachfolgender Auftrag den neuen Bestand nicht mehr im selben Tick +wegnehmen und dadurch einen falschen Retry oder Fehler ausloesen. + ## Create-Fabrik: Peripherie erkennen Das rein lesende Diagnoseprogramm herunterladen und starten: diff --git a/create_factory_scheduler.lua b/create_factory_scheduler.lua index 8cc836c..7368a3b 100644 --- a/create_factory_scheduler.lua +++ b/create_factory_scheduler.lua @@ -1,7 +1,7 @@ -- ATM10 Create factory scheduler V1 -- Persistent jobs, dependency planning, progress-aware retries and diagnostics. -local VERSION = "1.3.1" +local VERSION = "1.3.2" local REFRESH_SECONDS = 1 local CONFIRM_SECONDS = 6 local DRAIN_SECONDS = 60 @@ -97,7 +97,7 @@ local RECIPES = { output = "create:railway_casing", outputCount = 64, targetCount = 64, }, precision_mechanism = { - label = "16 GOLD SHEETS -> PRECISION", station = "precisionmechanism", address = "precisionmechanism", + label = "16 GOLD PLATES -> PRECISION", station = "precisionmechanism", address = "precisionmechanism", input = "alltheores:gold_plate", inputCount = 16, outputs = { "create:precision_mechanism" }, completion = "activity", }, @@ -443,6 +443,33 @@ end local newJob +local function dependencyReleased(job) + if not job.dependencyJobId then return true end + local dependency = findJobById(job.dependencyJobId) + if not dependency then + job.dependencyJobId, job.waitingFor = nil, nil + return true + end + if dependency.status == "FAILED" or dependency.status == "CANCELLED" then + failJob(job, "Vorauftrag #" .. dependency.id .. " fuer " + .. prettyItemName(job.waitingFor or "Input") .. " ist " .. dependency.status) + return false + end + + -- The parent may consume the result as soon as the child has registered its + -- complete arrival. Waiting for the whole drain timer is unnecessary, but + -- releasing it before this point makes the parent hide the child's output. + local target = math.max(1, dependency.targetCount or 1) + local registered = (dependency.progress or 0) >= target + if dependency.status ~= "DONE" and not registered then + job.status, job.activeStation = "WAITING_INPUT", nil + return false + end + + job.dependencyJobId, job.waitingFor, job.lastDependencyLog = nil, nil, nil + return true +end + local function waitForDependency(job, item, required) local producerId = PRODUCER_BY_ITEM[item] if not producerId or producerId == job.recipeId then @@ -480,6 +507,7 @@ end local function dispatchNormal(job, missingOutput) local recipe = RECIPES[job.recipeId] + if not dependencyReleased(job) then return false end local selectedStation = chooseStation(recipe, job) if not selectedStation then job.status = "WAITING" return false end