Better Robots Extended Space Age Compat


This mod is meant to rebalance Better Robots Extended for the Space Age expansion. To make the higher tier robots and roboports, you must leave Nauvis.

Tweaks
5 days ago
2.0
79
Planets Logistic network

g General feedback

19 days ago

I'm trying to figure out the research part of my mod. Any and all help is welcome.

7 days ago
(updated 7 days ago)

Hey Nightmare3711,

first of all, thanks for your mod – I really like the idea, it’s a cool addon concept 😄
I thought I’d give you a bit of help, since I know my own code and structure quite well 😉

From a technical perspective, all BRE technologies can be safely patched via data.raw.technology[...] (for example in data-final-fixes.lua).
Because some tech tiers depend on settings (max tier), it’s best to patch defensively and only if the technology actually exists.

As a simple gate condition, you can use something like this:

.

if not (mods["Better_Robots_Extended"] and mods["Space Age"]) then return end

local function add_pack(tech, pack)
tech.unit = tech.unit or {}
tech.unit.ingredients = tech.unit.ingredients or {}

for _, ing in ipairs(tech.unit.ingredients) do
if ing[1] == pack then return end
end

table.insert(tech.unit.ingredients, {pack, 1})
end

local function add_prereq(tech, prereq)
tech.prerequisites = tech.prerequisites or {}

for _, p in ipairs(tech.prerequisites) do
if p == prereq then return end
end

table.insert(tech.prerequisites, prereq)
end

local function remove_prereq(tech, prereq)
if not tech.prerequisites then return end

for i = #tech.prerequisites, 1, -1 do
if tech.prerequisites[i] == prereq then
table.remove(tech.prerequisites, i)
end
end
end

local function patch(name, fn)
local tech = data.raw.technology[name]
if tech then fn(tech) end
end

patch("BRE-construction-robotics-2", function(t)
-- add_prereq(t, "low-density-structure")
-- remove_prereq(t, "personal-battery")
-- add_pack(t, "utility-science-pack")
end)

patch("BRE-logistic-robotics-2", function(t)
-- add_prereq(t, "low-density-structure")
-- remove_prereq(t, "personal-battery")
-- add_pack(t, "utility-science-pack")
end)

patch("BRE-construction-robotics-3", function(t)
-- add_prereq(t, "electromagnetic-science-pack")
-- add_pack(t, "utility-science-pack")
-- add_pack(t, "production-science-pack")
-- add_pack(t, "electromagnetic-science-pack")
end)

patch("BRE-logistic-robotics-3", function(t)
-- add_prereq(t, "electromagnetic-science-pack")
-- add_pack(t, "utility-science-pack")
-- add_pack(t, "production-science-pack")
-- add_pack(t, "electromagnetic-science-pack")
end)

patch("BRE-construction-robotics-4", function(t)
-- add_prereq(t, "carbon-fiber")
-- add_prereq(t, "metallurgic-science-pack")
-- add_pack(t, "agricultural-science-pack")
-- add_pack(t, "metallurgic-science-pack")
end)

patch("BRE-logistic-robotics-4", function(t)
-- add_prereq(t, "carbon-fiber")
-- add_prereq(t, "metallurgic-science-pack")
-- add_pack(t, "agricultural-science-pack")
-- add_pack(t, "metallurgic-science-pack")
end)

patch("BRE-construction-robotics-5", function(t)
-- add_prereq(t, "quantum-processor")
-- add_pack(t, "cryogenic-science-pack")
end)

patch("BRE-logistic-robotics-5", function(t)
-- add_prereq(t, "quantum-processor")
-- add_pack(t, "cryogenic-science-pack")
end)

.

After that, you’re free to decide where and how you want to add Space Age science packs or prerequisites.
I would recommend avoiding changes to research count or time, since BRE already handles balance via settings – science packs and prerequisites are totally fine.
If you do want to adjust the research count, it becomes significantly more complex, as it is internally tied to settings that would then also need to be updated or reworked.

I haven’t tested the code myself, but it should work fine – sorry in advance if something needs a small tweak 😅

If you want, I’m happy to take another look at the SA tech progression or help with testing 😊

Thanks again for the work and the idea behind the addon!

5 days ago

I've done some (very little, but some) modding before with other games (YOMI HUSTLE, Minecraft, Terraria) but Factorio is my first exposure to lua iirc, so I'm still figuring some of this out. It's not too dissimilar to Minecraft I find, both sharing the helper code thing.

I uploaded the latest version with some of your code implemented, though I can't seem to get it to work for some reason. I'm not yet sure what I'm doing wrong.

5 days ago
(updated 5 days ago)

Hey Nightmare3711,

no worries at all – Lua + Factorio can be a bit confusing at first, especially once things start getting split into helpers and multiple files. I’ve definitely been there myself 😄

I went through all of the patches and cleaned them up so they now work correctly in-game. On my end, both the technology changes and the recipe changes are fully functional.

One thing I should mention up front (that’s on me): I accidentally gave you a slightly wrong dependency gate earlier.
I wrote
if not (mods["Better_Robots_Extended"] and mods["Space Age"]) then return end
but the correct mod name is actually space-age, not Space Age.
Because of that, the technology patches never ran. Once this is corrected, the tech changes apply as expected.

For clarification regarding the files:
data-final-fixes.lua is still based on your original implementation and structure.
The files technology_patch.lua and recipe_patch.lua were created from that to separate the logic more cleanly and make everything more robust – not to replace your original code.

Especially on the recipe side, a few things were broken before. Ingredients were partially handled as plain strings instead of using the ingredient format Factorio expects, which caused the recipe patches not to apply correctly at all.
This is now fixed: recipes are patched additively using helper functions. There are no global overrides and no full recipe replacements.

The same approach is used for technologies: nothing is overridden. Only science packs and prerequisites are added or removed additively, so everything stays compatible with BRE settings, tier limits, and other mods.

I also restructured the addon slightly to make it easier to follow and maintain:
- data-final-fixes.lua now only acts as an entry point / dispatcher
- all technology-related changes live in their own file
- all recipe-related changes live in their own file

I added more inline documentation to the helper functions as well, so it’s clearer what each function does and why it exists. One important design decision (now documented in the code) is that both recipe and technology patches only use add/remove helpers. Nothing is globally overridden.

Another important detail: in Better Robots Extended, research count and time are controlled via startup settings, so I deliberately avoided changing those. The tech patches only modify science packs and prerequisites.
For recipes, I added support for BRE’s internal cost() helper so ingredient amounts stay consistent with the user’s settings.

The patch helpers are intentionally kept generic so that new content can be integrated without any issues.
Both recipes and technologies can easily be extended with additional items, science packs, or prerequisites, without touching existing logic or using global overrides.

As a small heads-up for the future (totally optional):
there are still a few BRE entities that could also be extended with Space Age materials if you ever feel like expanding the addon further, for example:

  • BRE-roboport-mk2
  • BRE-roboport-mk3
  • BRE-robo-box-mk1 – mk3
  • BRE-robo-erweiterung-mk1 – mk3
  • BRE-robo-lader-mk1 – mk3

No pressure at all – just mentioning it in case you’re interested in giving those tiers a Space Age touch as well 🙂

If anything in the helper logic is unclear or you want to change how something works, feel free to ask. Happy to explain or help further.

Cheers 😊
Nick1Z2

New response