From dde44362e5f7285085f3778d7b8bceda3fe89eee Mon Sep 17 00:00:00 2001 From: Igor Kotrasinski Date: Sun, 3 May 2026 17:22:27 +0200 Subject: [PATCH 1/3] Machine upgrades mod support This allows machine upgrades added in "Planet Rubia" mod to be accounted for when planning. NOTE: this is just a PoC. The mod doesn't add productivity to finished products, as it works by adding hidden beacon entities with modules. This commit doesn't account for it yet and adds productivity to everything. --- modfiles/backend/data/Line.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modfiles/backend/data/Line.lua b/modfiles/backend/data/Line.lua index 2760f861..30d1721e 100644 --- a/modfiles/backend/data/Line.lua +++ b/modfiles/backend/data/Line.lua @@ -182,16 +182,26 @@ function Line:setup_beacon(player) end end +local has_mupgrades = remote.interfaces["machine-upgrades-get-modifiers"] ---@return boolean uses_effects function Line:uses_beacon_effects(player) return self.machine.proto.effect_receiver.uses_beacon_effects end - function Line:summarize_effects() local beacon_effects = (self.beacon) and self.beacon.total_effects or nil local merged_effects = util.effects.merge({self.machine.total_effects, beacon_effects}) + if has_mupgrades then + local name = self.machine.proto.name + local meffects = remote.call("machine-upgrades-get-modifiers", "get_modifiers", name) + -- We use percent, machine upgrades does not. + for item, v in pairs(meffects) do + meffects[item] = v * 100 + end + merged_effects = util.effects.merge({merged_effects, meffects}) + end + local limited_effects, indications = util.effects.limit(merged_effects, self.recipe.proto.maximum_productivity) self.total_effects = limited_effects From 9608498dc711579a471ff3c94ed970b9c75f41ec Mon Sep 17 00:00:00 2001 From: Igor Kotrasinski Date: Sun, 3 May 2026 19:04:54 +0200 Subject: [PATCH 2/3] Account for disallowed productivity modules Signed-off-by: Igor Kotrasinski --- modfiles/backend/data/Line.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modfiles/backend/data/Line.lua b/modfiles/backend/data/Line.lua index 30d1721e..a6bf4c20 100644 --- a/modfiles/backend/data/Line.lua +++ b/modfiles/backend/data/Line.lua @@ -195,6 +195,10 @@ function Line:summarize_effects() if has_mupgrades then local name = self.machine.proto.name local meffects = remote.call("machine-upgrades-get-modifiers", "get_modifiers", name) + local productivity_applicable = self.recipe.proto.allowed_effects["productivity"] + if not productivity_applicable then + meffects["productivity"] = 0 + end -- We use percent, machine upgrades does not. for item, v in pairs(meffects) do meffects[item] = v * 100 From 209c5b4b9ff29dd2c508276b53a3f74dc0667c11 Mon Sep 17 00:00:00 2001 From: Igor Kotrasinski Date: Sun, 3 May 2026 21:18:14 +0200 Subject: [PATCH 3/3] Protect from nil recipe proto Signed-off-by: Igor Kotrasinski --- modfiles/backend/data/Line.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modfiles/backend/data/Line.lua b/modfiles/backend/data/Line.lua index a6bf4c20..ca1d2d6d 100644 --- a/modfiles/backend/data/Line.lua +++ b/modfiles/backend/data/Line.lua @@ -195,7 +195,9 @@ function Line:summarize_effects() if has_mupgrades then local name = self.machine.proto.name local meffects = remote.call("machine-upgrades-get-modifiers", "get_modifiers", name) - local productivity_applicable = self.recipe.proto.allowed_effects["productivity"] + local e = self.recipe.proto.allowed_effects + local productivity_applicable = false + if e ~= nil then productivity_applicable = e["productivity"] end if not productivity_applicable then meffects["productivity"] = 0 end