From ec8fe81d3e09c351f02eb564b009ee6b9a89fba4 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Sat, 25 Jan 2025 10:52:32 +0100 Subject: [PATCH] Add mod support for science packs and custom labs And fix Cerys incompatibility --- README.md | 68 ++++++++++++++++--- lignumis/data.lua | 19 +++++- .../integrations/vanilla-updates.lua | 17 +++-- lignumis/prototypes/integrations/vanilla.lua | 12 ---- 4 files changed, 90 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 022a2a7..3b41a12 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,16 @@ -This mod extends the early game of Space Age by putting you on the moon "Lignumis" before you escape to Nauvis. It concentrates on wood and steam technologies, giving you some early game production chains for those resources. +This mod extends the early game of Space Age by putting you on the moon "Lignumis" before you escape to Nauvis. It +concentrates on wood and steam technologies, giving you some early game production chains for those resources. -The duration of the stay on Lignumis will be rather short. The impact of the later game will still be substantial (once implemented). +The duration of the stay on Lignumis will be rather short. The impact of the later game will still be substantial (once +implemented). ## Beta version -This is an early version of the mod. It contains all the content that was originally planned but still needs some balancing and polishing. +This is an early version of the mod. It contains all the content that was originally planned but still needs some +balancing and polishing. -**Please help me finish this mod by giving me feedback of any kind (e.g. odd, missing or broken things, ideas to improve mechanics or progression or anything else that comes to your mind).** +**Please help me finish this mod by giving me feedback of any kind (e.g. odd, missing or broken things, ideas to improve +mechanics or progression or anything else that comes to your mind).** If you like to contribute in any other way, feel free to contact me as well. @@ -20,13 +24,16 @@ There will be fewer inserters that need to be fueled manually. #### [Hot metals](https://mods.factorio.com/mod/hot-metals) -If you like the idea that metals need to cool down after being smolten in a furnace, Lignumis gold has support for hot metals. +If you like the idea that metals need to cool down after being smolten in a furnace, Lignumis gold has support for hot +metals. -*Note that you'll have to insert gold plates manually into the provisional rocket silo when Hot metals is active (See https://forums.factorio.com/viewtopic.php?f=48&t=123081).* +*Note that you'll have to insert gold plates manually into the provisional rocket silo when Hot metals is active ( +See https://forums.factorio.com/viewtopic.php?f=48&t=123081).* #### [Wooden Military](https://mods.factorio.com/mod/wood-military) -If you want more of it than Lignumis offers, add this mod. It adds ammo for shotguns and there are settings for rockets and artillery shells. +If you want more of it than Lignumis offers, add this mod. It adds ammo for shotguns and there are settings for rockets +and artillery shells. #### [Wooden Industry](https://mods.factorio.com/mod/wood-industry) @@ -36,13 +43,56 @@ If you like go more into the charcoal direction. It has no overlap with Lignumis For wood on the other planets. +## Add compatibility to your mod + +Lignumis, by default, adds wood and steam science packs during `data-updates.lua` to all technologies that match certain +criteria. +First it looks at a whitelist of science packs. If a technology has any of those, it is considered a candidate for +adding the science packs. +Then a blacklist for science packs and specific technology names is applied. + +Also, Lignumis adds wood and steam science packs during `data-updates.lua` to all labs' inputs. If your lab is special +use the `lab_blacklist` described below. + +These lists are made available in `data.lua` in a global table called `Lignumis` to add compatibility for other mods. + +#### `science_pack_whitelist` + +A technology having any of these science packs as ingredient will get wood and steam science packs added. + +As wood science packs can't be imported before coming back to Lignumis, only advanced Nauvis science packs are added +here and exceptions are needed for advanced technologies that are required to upgrade Lignumis to export science packs. + +#### `science_pack_blacklist` + +A technology is skipped if it has any of these as ingredient. + +If you have a planet that only uses its own science packs and must not rely on other science packs to be imported, add +your science packs to the blacklist. + +#### `science_blacklist` + +These technologies are skipped even if they are matches according to above lists. + +Use this list if you want to have wood and steam science packs added to most of your technologies, but skip some. +Lignumis uses this list for technologies that match the whitelist but are required for coming back to Lignumis in order +to create the science pack export. + +#### `lab_blacklist` + +Don't touch inputs for labs in this list. + +Lignumis adds wood and steam science packs to all labs' inputs in `data-updates.lua` so modded labs will support them. +If your modded lab is special and it should not support these science packs, use this list or set the inputs in `data-final-fixes.lua`. + ## Todo Sorted by priority - Fix pipe graphics on desiccation furnace and quality assembler - Ban huge rocks with coal from Nauvis -- Create proper experience for the transition to Nauvis with a custom UI with launch button (and don't allow taking your inventory) +- Create proper experience for the transition to Nauvis with a custom UI with launch button (and don't allow taking your + inventory) - Add more description strings - Tweak all custom graphics colors - Optimize images @@ -52,7 +102,7 @@ Sorted by priority - Revisit compatibility with [AAI Industry](https://mods.factorio.com/mod/aai-industry) - Move pollution surface property to separate mod - Trees must not die when absorbing noise - - https://lua-api.factorio.com/latest/types/TreeVariation.html + - https://lua-api.factorio.com/latest/types/TreeVariation.html ## Credits diff --git a/lignumis/data.lua b/lignumis/data.lua index a237c35..26aeedd 100644 --- a/lignumis/data.lua +++ b/lignumis/data.lua @@ -1,10 +1,27 @@ Lignumis = { + -- A technology having any of these science packs as ingredient will get wood and steam science packs added + science_pack_whitelist = { "utility-science-pack", "production-science-pack", "space-science-pack" }, + + -- A technology is skipped if it has any of these as ingredient + science_pack_blacklist = { + "wood-science-pack", "steam-science-pack", -- Lignumis + "nanite-science-pack", "quantum-science-pack", "ring-science-pack", -- Metal and Stars + "cerys-science-pack" -- Cerys + }, + + -- These technologies are skipped even if they are matches according to above lists science_blacklist = { "deep-miner", "logistic-system", "space-platform-thruster", "kovarex-enrichment-process", "astroponics" + }, + + -- Add wood and steam science packs to all labs' inputs except these + lab_blacklist = { + "wood-lab", -- Lignumis + "cerys-lab" -- Cerys } } @@ -12,4 +29,4 @@ require("__cf-lib__/util") require("prototypes/content/data") require("prototypes/integrations/data") -require("prototypes/compatibility/data") +require("prototypes/compatibility/data") \ No newline at end of file diff --git a/lignumis/prototypes/integrations/vanilla-updates.lua b/lignumis/prototypes/integrations/vanilla-updates.lua index 84abf14..3b5a41a 100644 --- a/lignumis/prototypes/integrations/vanilla-updates.lua +++ b/lignumis/prototypes/integrations/vanilla-updates.lua @@ -1,14 +1,12 @@ -- Add wood and steam science packs as ingredients to technologies that require Nauvis science packs. --- It skips technologies that are available before coming back to Lignumis. - for _, technology in pairs(data.raw.technology) do if technology.unit and technology.unit.ingredients and not table.contains(Lignumis.science_blacklist, technology.name) then local ingredients = technology.unit.ingredients local noMatches = table.filter(ingredients, function(ingredient) - return table.contains({ "wood-science-pack", "steam-science-pack", "nanite-science-pack", "quantum-science-pack", "ring-science-pack" }, ingredient[1]) + return table.contains(Lignumis.science_pack_blacklist, ingredient[1]) end) local yesMatches = table.filter(ingredients, function(ingredient) - return table.contains({ "utility-science-pack", "production-science-pack", "space-science-pack" }, ingredient[1]) + return table.contains(Lignumis.science_pack_whitelist, ingredient[1]) end) if #noMatches == 0 and #yesMatches > 0 then table.insert(technology.unit.ingredients, { "wood-science-pack", 1 }) @@ -16,3 +14,14 @@ for _, technology in pairs(data.raw.technology) do end end end + + +-- Add wood and steam science packs to all labs' inputs +for _, lab in pairs(data.raw.lab) do + if lab.inputs and not table.contains(Lignumis.lab_blacklist, lab.name) then + lab.inputs = table.assign({ + "wood-science-pack", + "steam-science-pack" + }, lab.inputs) + end +end \ No newline at end of file diff --git a/lignumis/prototypes/integrations/vanilla.lua b/lignumis/prototypes/integrations/vanilla.lua index 00a3b89..5bafcd8 100644 --- a/lignumis/prototypes/integrations/vanilla.lua +++ b/lignumis/prototypes/integrations/vanilla.lua @@ -44,18 +44,6 @@ data.raw.recipe["burner-inserter"].ingredients = { -- Lab -local lab = data.raw["lab"]["lab"] -lab.inputs = table.assign({ - "wood-science-pack", - "steam-science-pack" -}, lab.inputs) - -local biolab = data.raw["lab"]["biolab"] -biolab.inputs = table.assign({ - "wood-science-pack", - "steam-science-pack" -}, biolab.inputs) - local lab_recipe = data.raw.recipe["lab"] for _, ingredient in pairs(lab_recipe.ingredients) do if ingredient.name == "transport-belt" then