From 3d15a431f2324630f918b76e747f3f42f6fea898 Mon Sep 17 00:00:00 2001 From: pla Date: Tue, 28 Oct 2025 09:16:11 +0100 Subject: [PATCH 01/15] Fix early tech tree without K2 --- bzgas2/data-final-fixes.lua | 21 +++++++++++++++------ bzgas2/data-util.lua | 9 +++++++++ bzgas2/data.lua | 2 +- bzgas2/prototypes/bakelite.lua | 1 + bzgas2/prototypes/gas-extractor.lua | 12 +++++------- bzgas2/prototypes/phenol.lua | 11 +++-------- 6 files changed, 34 insertions(+), 22 deletions(-) diff --git a/bzgas2/data-final-fixes.lua b/bzgas2/data-final-fixes.lua index ad08a6f..70ec7e8 100644 --- a/bzgas2/data-final-fixes.lua +++ b/bzgas2/data-final-fixes.lua @@ -2,7 +2,7 @@ require("stacking") require("modules") require("compatibility/ir2") -local util = require("data-util"); +local util = require("__bzgas2__/data-util") -- core mining balancing util.set_product_amount("se-core-fragment-omni", "gas", 24) @@ -30,13 +30,22 @@ if not mods.Krastorio2 and not mods["aai-industry"] and not mods.bzaluminum2 and util.add_ingredient("repair-pack", "copper-cable", 6) util.set_ingredient("repair-pack", "iron-gear-wheel", 3) - util.add_unlock_force("electronics", "electronic-circuit") - util.add_effect("electronics", { type = "unlock-recipe", recipe = "inserter" }) + -- New for 2.0 (Evilpla) + util.remove_prerequisite("automation", "automation-science-pack") + util.set_tech_trigger("automation", { type = "mine-entity", entity = "coal" }) + util.set_tech_trigger("gas-extraction", { type = "craft-item", item = "copper-plate" }) + util.set_tech_trigger("basic-chemistry", { type = "mine-entity", entity = "gas" }) + util.set_tech_trigger("bakelite", { type = "craft-fluid", fluid = "formaldehyde" }) + util.set_tech_trigger("electronics", { type = "craft-item", item = "bakelite" }) util.add_effect("electronics", { type = "unlock-recipe", recipe = "long-handed-inserter" }) util.remove_recipe_effect("automation", "long-handed-inserter") - util.set_enabled("electronic-circuit", false) - util.set_enabled("inserter", false) - util.add_prerequisite("logistic-science-pack", "electronics") + + -- TODO: cleanup + -- util.add_unlock_force("electronics", "electronic-circuit") + -- util.add_effect("electronics", { type = "unlock-recipe", recipe = "inserter" }) + -- util.set_enabled("electronic-circuit", false) + -- util.set_enabled("inserter", false) + -- util.add_prerequisite("logistic-science-pack", "electronics") end if not mods.bzaluminum2 and not mods["bzcarbon2"] then util.replace_ingredients_prior_to("electronics", "electronic-circuit", "copper-cable", 2) diff --git a/bzgas2/data-util.lua b/bzgas2/data-util.lua index ff75c36..5dbd855 100644 --- a/bzgas2/data-util.lua +++ b/bzgas2/data-util.lua @@ -1267,4 +1267,13 @@ function util.set_vtk_dcm_ingredients() end end +-- Set technology trigger +function util.set_tech_trigger(technology_name, trigger) + local technology = data.raw.technology[technology_name] + if technology then + technology.unit = nil + technology.research_trigger = trigger + end +end + return util diff --git a/bzgas2/data.lua b/bzgas2/data.lua index 26625fe..6c2e79d 100644 --- a/bzgas2/data.lua +++ b/bzgas2/data.lua @@ -1,7 +1,7 @@ require("prototypes/gas") require("prototypes/gas-extractor") -require("prototypes/phenol") require("prototypes/formaldehyde") +require("prototypes/phenol") require("prototypes/bakelite") require("prototypes/basic-chemical-plant") require("prototypes/k2-recipe") diff --git a/bzgas2/prototypes/bakelite.lua b/bzgas2/prototypes/bakelite.lua index 83a7a9d..1b15bd2 100644 --- a/bzgas2/prototypes/bakelite.lua +++ b/bzgas2/prototypes/bakelite.lua @@ -15,6 +15,7 @@ data:extend({ name = "bakelite", category = "chemistry", main_product = "bakelite", + allow_productivity = true, enabled = false, ingredients = { {type = "item", name = util.me.use_phenol() and "phenol" or "coal", amount = 1}, diff --git a/bzgas2/prototypes/gas-extractor.lua b/bzgas2/prototypes/gas-extractor.lua index 156b547..d749ae7 100644 --- a/bzgas2/prototypes/gas-extractor.lua +++ b/bzgas2/prototypes/gas-extractor.lua @@ -1,4 +1,4 @@ -local util = require("data-util"); +local util = require("data-util") local futil = require("util") local ge_ingredients = { @@ -14,9 +14,6 @@ if mods.Krastorio2 then elseif mods["aai-industry"] then table.insert(ge_ingredients, {type="item", name="sand", amount=10}) ge_prereq = {"sand-processing"} -elseif data.raw.item["silica"] and data.raw.technology["silica-processing"] then - table.insert(ge_ingredients, {type="item", name="silica", amount=20}) - ge_prereq = {"silica-processing"} end drilling_rig_circuit_connector_definitions = circuit_connector_definitions.create_vector @@ -46,7 +43,7 @@ data:extend({ type = "recipe", name = "gas-extractor", results = {{ type = "item", name = "gas-extractor", amount = 1}}, - enabled = false, -- TODO change + enabled = false, ingredients = ge_ingredients, }, { @@ -54,7 +51,7 @@ data:extend({ name = "gas-extraction", icon = "__bzgas2__/graphics/technology/gas-processing.png", icon_size = 256, - --prerequisites = ge_prereq, + prerequisites = ge_prereq, effects = { {type = "unlock-recipe", recipe = "gas-extractor"}, }, @@ -87,11 +84,12 @@ data:extend({ }, output_fluid_box = { - volume = 1000, + volume = 100, pipe_covers = pipecoverspictures(), pipe_connections = { { + flow_direction = "output", direction = defines.direction.north, positions = { {0, -1}, {1, 0}, {0, 1}, {-1, 0} } } diff --git a/bzgas2/prototypes/phenol.lua b/bzgas2/prototypes/phenol.lua index 538bada..ad83ed6 100644 --- a/bzgas2/prototypes/phenol.lua +++ b/bzgas2/prototypes/phenol.lua @@ -1,4 +1,4 @@ -local util = require("data-util"); +local util = require("data-util") if util.me.use_phenol() then @@ -66,13 +66,8 @@ if data.raw.item[mods["Krastorio2"] and "kr-coke" or "coke"] then } }) end - if mods.Krastorio2 then - util.add_effect("steel-processing", {type="unlock-recipe", recipe="phenol"}) - elseif data.raw.item["foundry"] then - util.add_effect("foundry", {type="unlock-recipe", recipe="phenol"}) - else - util.add_effect("basic-chemistry", {type="unlock-recipe", recipe="phenol"}) - end + + util.add_effect("basic-chemistry", {type="unlock-recipe", recipe="phenol"}) if mods.Krastorio2 then light_oil_icon = { icon = "__Krastorio2Assets__/icons/fluids/light-oil.png", icon_size = 64, icon_mipmaps = 4, scale=0.25, shift={-8,-8}} From 3a045a5cbae92f2d0b56c419eb280543c4d0b095 Mon Sep 17 00:00:00 2001 From: pla Date: Tue, 28 Oct 2025 10:04:49 +0100 Subject: [PATCH 02/15] Fix K2 matter recipe generation and tech icon --- bzgas2/matter.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bzgas2/matter.lua b/bzgas2/matter.lua index acf60cf..2b5e943 100644 --- a/bzgas2/matter.lua +++ b/bzgas2/matter.lua @@ -17,9 +17,10 @@ data:extend( { icon = "__bzgas2__/graphics/icons/gas.png", icon_size = 128, - scale = 1.4, + scale = 0.7, } }, + effects ={}, prerequisites = {"kr-matter-processing"}, unit = { @@ -40,8 +41,8 @@ local gas_ore_matter = material = { type = "fluid", name = "gas", amount = 100 }, matter_count = 5, energy_required = 1, - need_stabilizer = false, - unlocked_by_technology = "gas-matter-processing" + needs_stabilizer = false, + unlocked_by = "gas-matter-processing" } matter.make_recipes(gas_ore_matter) end From 5c7fc47c3423563cd3853f4afba84e90b0d50b12 Mon Sep 17 00:00:00 2001 From: pla Date: Fri, 31 Oct 2025 17:29:56 +0100 Subject: [PATCH 03/15] set proper subgoup for liquids --- bzgas2/prototypes/formaldehyde.lua | 3 ++- bzgas2/prototypes/gas.lua | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bzgas2/prototypes/formaldehyde.lua b/bzgas2/prototypes/formaldehyde.lua index 36b0be4..3880d8b 100644 --- a/bzgas2/prototypes/formaldehyde.lua +++ b/bzgas2/prototypes/formaldehyde.lua @@ -1,4 +1,4 @@ -local util = require("data-util"); +local util = require("data-util") -- data:extend({ -- { @@ -11,6 +11,7 @@ data:extend({ { type = "fluid", name = "formaldehyde", + subgroup = "fluid", default_temperature = 25, heat_capacity = "0.1kJ", fuel_value = "0.5kJ", diff --git a/bzgas2/prototypes/gas.lua b/bzgas2/prototypes/gas.lua index 3a9325c..c394409 100644 --- a/bzgas2/prototypes/gas.lua +++ b/bzgas2/prototypes/gas.lua @@ -1,6 +1,6 @@ -local resource_autoplace = require('resource-autoplace'); +local resource_autoplace = require('resource-autoplace') -local util = require("data-util"); +local util = require("data-util") local futil = require("util") data.raw.planet.nauvis.map_gen_settings.autoplace_controls["gas"] = {} @@ -104,6 +104,7 @@ data:extend({ { type = "fluid", name = "gas", + subgroup = "fluid", default_temperature = 25, heat_capacity = "0.1kJ", fuel_value = "1000kJ", From 3ba05c70c2a094e0a929dd59e5251e96c349a21f Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Tue, 4 Nov 2025 23:15:56 +0100 Subject: [PATCH 04/15] Fix early game technologies with only bzgas --- bzgas2/data-final-fixes.lua | 22 ++++++++++++++++++++-- bzgas2/prototypes/gas-extractor.lua | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/bzgas2/data-final-fixes.lua b/bzgas2/data-final-fixes.lua index ad08a6f..b23574f 100644 --- a/bzgas2/data-final-fixes.lua +++ b/bzgas2/data-final-fixes.lua @@ -30,13 +30,31 @@ if not mods.Krastorio2 and not mods["aai-industry"] and not mods.bzaluminum2 and util.add_ingredient("repair-pack", "copper-cable", 6) util.set_ingredient("repair-pack", "iron-gear-wheel", 3) - util.add_unlock_force("electronics", "electronic-circuit") - util.add_effect("electronics", { type = "unlock-recipe", recipe = "inserter" }) util.add_effect("electronics", { type = "unlock-recipe", recipe = "long-handed-inserter" }) + util.remove_recipe_effect("electronics", "copper-cable") + util.remove_recipe_effect("electronics", "lab") + util.remove_recipe_effect("electronics", "small-electric-pole") util.remove_recipe_effect("automation", "long-handed-inserter") util.set_enabled("electronic-circuit", false) util.set_enabled("inserter", false) + util.set_enabled("copper-cable", true) + util.set_enabled("lab", true) + util.set_enabled("small-electric-pole", true) + util.remove_prerequisite("automation-science-pack", "electronics") + local electronics = data.raw.technology["electronics"] + electronics.research_trigger = nil + electronics.unit = { + count = 10, + time = 10, + ingredients = {{ "automation-science-pack", 1 }} + } + util.remove_prerequisite("fast-inserter", "automation-science-pack") + util.remove_prerequisite("lamp", "automation-science-pack") + util.remove_prerequisite("logistic-science-pack", "automation-science-pack") + util.add_prerequisite("fast-inserter", "electronics") + util.add_prerequisite("lamp", "electronics") util.add_prerequisite("logistic-science-pack", "electronics") + end if not mods.bzaluminum2 and not mods["bzcarbon2"] then util.replace_ingredients_prior_to("electronics", "electronic-circuit", "copper-cable", 2) diff --git a/bzgas2/prototypes/gas-extractor.lua b/bzgas2/prototypes/gas-extractor.lua index 156b547..cd9c3ae 100644 --- a/bzgas2/prototypes/gas-extractor.lua +++ b/bzgas2/prototypes/gas-extractor.lua @@ -54,7 +54,7 @@ data:extend({ name = "gas-extraction", icon = "__bzgas2__/graphics/technology/gas-processing.png", icon_size = 256, - --prerequisites = ge_prereq, + prerequisites = ge_prereq, effects = { {type = "unlock-recipe", recipe = "gas-extractor"}, }, From c3c414f36a77ab480fb0a5647702f33716bdf654 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Tue, 4 Nov 2025 23:34:11 +0100 Subject: [PATCH 05/15] Fix early game technologies with bzfoundry --- bzgas2/prototypes/bakelite.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bzgas2/prototypes/bakelite.lua b/bzgas2/prototypes/bakelite.lua index 83a7a9d..7b7ceed 100644 --- a/bzgas2/prototypes/bakelite.lua +++ b/bzgas2/prototypes/bakelite.lua @@ -1,5 +1,10 @@ local util = require("data-util"); +local prereq = {"basic-chemistry"} +if mods["bzfoundry2"] then + table.insert(prereq, "foundry") +end + data:extend({ { type = "item", @@ -30,7 +35,7 @@ data:extend({ name = "bakelite", icon = "__bzgas2__/graphics/technology/bakelite.png", icon_size = 256, - prerequisites = {"basic-chemistry"}, + prerequisites = prereq, effects = { {type = "unlock-recipe", recipe = "bakelite"}, }, From 1b5895b421d84ab90f717fd9236665ac225e94c4 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Tue, 4 Nov 2025 23:55:58 +0100 Subject: [PATCH 06/15] Fix hand craft only recipe name --- bzgas2/compatibility/electronic-circuit.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/bzgas2/compatibility/electronic-circuit.lua b/bzgas2/compatibility/electronic-circuit.lua index 65995f0..1dc0e02 100644 --- a/bzgas2/compatibility/electronic-circuit.lua +++ b/bzgas2/compatibility/electronic-circuit.lua @@ -27,6 +27,7 @@ if util.me.handcraft() then end local hcec = futil.table.deepcopy(data.raw.recipe["electronic-circuit"]) hcec.name = "electronic-circuit-handcraft-only" + hcec.localized_name = { "item-name.electronic-circuit" } data:extend({hcec}) util.set_icons("electronic-circuit-handcraft-only", { From 6c0876d0c8f5b3b50d5efd1d5ba91310242434a9 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Wed, 5 Nov 2025 00:22:10 +0100 Subject: [PATCH 07/15] Fix early game technologies with Krastorio --- bzgas2/data-final-fixes.lua | 6 +++--- bzgas2/prototypes/bakelite.lua | 4 +++- bzgas2/prototypes/formaldehyde.lua | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bzgas2/data-final-fixes.lua b/bzgas2/data-final-fixes.lua index b23574f..dfa6292 100644 --- a/bzgas2/data-final-fixes.lua +++ b/bzgas2/data-final-fixes.lua @@ -9,9 +9,9 @@ util.set_product_amount("se-core-fragment-omni", "gas", 24) -- Fix basic chemical plant fuels for K2 if mods.Krastorio2 and -data.raw["assembling-machine"]["basic-chemical-plant"] and -data.raw["assembling-machine"]["basic-chemical-plant"].energy_source and -data.raw["assembling-machine"]["basic-chemical-plant"].energy_source.fuel_categories then + data.raw["assembling-machine"]["basic-chemical-plant"] and + data.raw["assembling-machine"]["basic-chemical-plant"].energy_source and + data.raw["assembling-machine"]["basic-chemical-plant"].energy_source.fuel_categories then table.insert(data.raw["assembling-machine"]["basic-chemical-plant"].energy_source.fuel_categories , "kr-vehicle-fuel") end diff --git a/bzgas2/prototypes/bakelite.lua b/bzgas2/prototypes/bakelite.lua index 7b7ceed..4597f08 100644 --- a/bzgas2/prototypes/bakelite.lua +++ b/bzgas2/prototypes/bakelite.lua @@ -1,7 +1,9 @@ local util = require("data-util"); local prereq = {"basic-chemistry"} -if mods["bzfoundry2"] then +if mods["Krastorio2"] then + table.insert(prereq, "steel-processing") +elseif mods["bzfoundry2"] then table.insert(prereq, "foundry") end diff --git a/bzgas2/prototypes/formaldehyde.lua b/bzgas2/prototypes/formaldehyde.lua index 36b0be4..66724e3 100644 --- a/bzgas2/prototypes/formaldehyde.lua +++ b/bzgas2/prototypes/formaldehyde.lua @@ -7,6 +7,11 @@ local util = require("data-util"); -- } -- }) +local prereq = {"gas-extraction"} +if mods["Krastorio2"] then + table.insert(prereq, "automation-science-pack") +end + data:extend({ { type = "fluid", @@ -40,7 +45,7 @@ data:extend({ name = "basic-chemistry", icon = "__bzgas2__/graphics/technology/formaldehyde.png", icon_size = 256, - prerequisites = {"gas-extraction"}, + prerequisites = prereq, effects = { {type = "unlock-recipe", recipe = "basic-chemical-plant"}, {type = "unlock-recipe", recipe = "formaldehyde"}, From 46e9a0ce4edaac57d73dedcf9eef77d7f2a31dc9 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Wed, 5 Nov 2025 09:44:29 +0100 Subject: [PATCH 08/15] Fix early game technologies with AAI Industry --- bzgas2/compatibility/electronic-circuit.lua | 2 +- bzgas2/data-final-fixes.lua | 4 ++++ bzgas2/prototypes/bakelite.lua | 2 ++ bzgas2/prototypes/gas-extractor.lua | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bzgas2/compatibility/electronic-circuit.lua b/bzgas2/compatibility/electronic-circuit.lua index 1dc0e02..74a3440 100644 --- a/bzgas2/compatibility/electronic-circuit.lua +++ b/bzgas2/compatibility/electronic-circuit.lua @@ -18,7 +18,7 @@ util.add_ingredient("electronic-circuit", "bakelite", amt) util.set_icons("electronic-circuit", nil) -if util.me.handcraft() then +if util.me.handcraft() and not mods["aai-industry"] then data:extend({{ type = "recipe-category", name = "handcraft-only" }}) for i, character in pairs(data.raw.character) do if character and character.crafting_categories then diff --git a/bzgas2/data-final-fixes.lua b/bzgas2/data-final-fixes.lua index dfa6292..e39b171 100644 --- a/bzgas2/data-final-fixes.lua +++ b/bzgas2/data-final-fixes.lua @@ -15,6 +15,10 @@ if mods.Krastorio2 and table.insert(data.raw["assembling-machine"]["basic-chemical-plant"].energy_source.fuel_categories , "kr-vehicle-fuel") end +if mods["aai-industry"] and not mods["Krastorio2"] then + util.remove_prerequisite("basic-chemistry", "basic-fluid-handling") +end + -- Vanilla burner phase tweaks -- green circuits after electronics -- Electronic circuit recipe set below in compatibility script if not mods.Krastorio2 and not mods["aai-industry"] and not mods.bzaluminum2 and not mods["bzcarbon2"] then diff --git a/bzgas2/prototypes/bakelite.lua b/bzgas2/prototypes/bakelite.lua index 4597f08..e4815d1 100644 --- a/bzgas2/prototypes/bakelite.lua +++ b/bzgas2/prototypes/bakelite.lua @@ -5,6 +5,8 @@ if mods["Krastorio2"] then table.insert(prereq, "steel-processing") elseif mods["bzfoundry2"] then table.insert(prereq, "foundry") +elseif mods["aai-industry"] then + table.insert(prereq, "automation") end data:extend({ diff --git a/bzgas2/prototypes/gas-extractor.lua b/bzgas2/prototypes/gas-extractor.lua index cd9c3ae..e7f3508 100644 --- a/bzgas2/prototypes/gas-extractor.lua +++ b/bzgas2/prototypes/gas-extractor.lua @@ -13,7 +13,7 @@ if mods.Krastorio2 then ge_prereq = {"kr-stone-processing"} elseif mods["aai-industry"] then table.insert(ge_ingredients, {type="item", name="sand", amount=10}) - ge_prereq = {"sand-processing"} + ge_prereq = {"sand-processing", "basic-fluid-handling"} elseif data.raw.item["silica"] and data.raw.technology["silica-processing"] then table.insert(ge_ingredients, {type="item", name="silica", amount=20}) ge_prereq = {"silica-processing"} From 8044c9d846003a8e4be142465135509fa33ab543 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Wed, 5 Nov 2025 10:12:25 +0100 Subject: [PATCH 09/15] 2.0.3 --- bzgas2/changelog.txt | 5 +++++ bzgas2/info.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bzgas2/changelog.txt b/bzgas2/changelog.txt index 42c0650..b303e3c 100644 --- a/bzgas2/changelog.txt +++ b/bzgas2/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 2.0.3 +Date: 05.11.2025 + Bug Fixes: + - Fix early game progression +--------------------------------------------------------------------------------------------------- Version: 2.0.2 Date: 22.10.2025 Bug Fixes: diff --git a/bzgas2/info.json b/bzgas2/info.json index ebae08f..bdcec07 100644 --- a/bzgas2/info.json +++ b/bzgas2/info.json @@ -1,6 +1,6 @@ { "name": "bzgas2", - "version": "2.0.2", + "version": "2.0.3", "factorio_version": "2.0", "title": "Natural Gas", "description": "Adds a natural gas resource, along with early game plastic.", From 4590fa6b98e17db49caaa5178dfe962dd7081972 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Wed, 5 Nov 2025 17:24:27 +0100 Subject: [PATCH 10/15] Fix hand craft only recipe name --- bzgas2/compatibility/electronic-circuit.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bzgas2/compatibility/electronic-circuit.lua b/bzgas2/compatibility/electronic-circuit.lua index 74a3440..e1f9aef 100644 --- a/bzgas2/compatibility/electronic-circuit.lua +++ b/bzgas2/compatibility/electronic-circuit.lua @@ -27,7 +27,7 @@ if util.me.handcraft() and not mods["aai-industry"] then end local hcec = futil.table.deepcopy(data.raw.recipe["electronic-circuit"]) hcec.name = "electronic-circuit-handcraft-only" - hcec.localized_name = { "item-name.electronic-circuit" } + hcec.localised_name = { "item-name.electronic-circuit" } data:extend({hcec}) util.set_icons("electronic-circuit-handcraft-only", { From afc504c7893183e7f6c84f06fc424b5c71c2f2b5 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Sat, 8 Nov 2025 21:17:11 +0100 Subject: [PATCH 11/15] 2.0.4 --- bzgas2/changelog.txt | 5 +++++ bzgas2/info.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bzgas2/changelog.txt b/bzgas2/changelog.txt index b303e3c..d7257f7 100644 --- a/bzgas2/changelog.txt +++ b/bzgas2/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 2.0.4 +Date: 08.11.2025 + Bug Fixes: + - Fix recipe name +--------------------------------------------------------------------------------------------------- Version: 2.0.3 Date: 05.11.2025 Bug Fixes: diff --git a/bzgas2/info.json b/bzgas2/info.json index bdcec07..847aa81 100644 --- a/bzgas2/info.json +++ b/bzgas2/info.json @@ -1,6 +1,6 @@ { "name": "bzgas2", - "version": "2.0.3", + "version": "2.0.4", "factorio_version": "2.0", "title": "Natural Gas", "description": "Adds a natural gas resource, along with early game plastic.", From 64d1305c45c6ceef9001f662cf8ce8884581860a Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Wed, 10 Dec 2025 19:19:33 +0100 Subject: [PATCH 12/15] Fix for when foundry is disabled in settings --- bzgas2/prototypes/bakelite.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bzgas2/prototypes/bakelite.lua b/bzgas2/prototypes/bakelite.lua index e4815d1..c5c0a29 100644 --- a/bzgas2/prototypes/bakelite.lua +++ b/bzgas2/prototypes/bakelite.lua @@ -3,7 +3,7 @@ local util = require("data-util"); local prereq = {"basic-chemistry"} if mods["Krastorio2"] then table.insert(prereq, "steel-processing") -elseif mods["bzfoundry2"] then +elseif util.is_foundry() then table.insert(prereq, "foundry") elseif mods["aai-industry"] then table.insert(prereq, "automation") From 959b3dea1d96fde4713c626c6e33f69b6c434d30 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Wed, 10 Dec 2025 19:55:04 +0100 Subject: [PATCH 13/15] 2.0.5 --- bzgas2/changelog.txt | 5 +++++ bzgas2/info.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bzgas2/changelog.txt b/bzgas2/changelog.txt index d7257f7..98de4c9 100644 --- a/bzgas2/changelog.txt +++ b/bzgas2/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 2.0.5 +Date: 10.12.2025 + Bug Fixes: + - Fix for when foundry is disabled in settings +--------------------------------------------------------------------------------------------------- Version: 2.0.4 Date: 08.11.2025 Bug Fixes: diff --git a/bzgas2/info.json b/bzgas2/info.json index 847aa81..d6c756c 100644 --- a/bzgas2/info.json +++ b/bzgas2/info.json @@ -1,6 +1,6 @@ { "name": "bzgas2", - "version": "2.0.4", + "version": "2.0.5", "factorio_version": "2.0", "title": "Natural Gas", "description": "Adds a natural gas resource, along with early game plastic.", From 43134465adf115bddf4d44e5f9a1ab9f42b46fb4 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Wed, 11 Mar 2026 22:03:44 +0100 Subject: [PATCH 14/15] Switch to bzlib --- bzgas2/data-util.lua | 1272 +----------------------------------------- bzgas2/info.json | 1 + 2 files changed, 4 insertions(+), 1269 deletions(-) diff --git a/bzgas2/data-util.lua b/bzgas2/data-util.lua index ff75c36..e2cbe2a 100644 --- a/bzgas2/data-util.lua +++ b/bzgas2/data-util.lua @@ -1,1270 +1,4 @@ --- WARNING WARNING WARNING --- This file will be overwritten in mod zipfiles, edit bzlib/data-util.lua --- WARNING WARNING WARNING - local me = require("me") -local util = {} - -util.me = me -util.get_setting = util.me.get_setting - -util.titanium_plate = "" -util.titanium_processing = "" - -if mods["FactorioExtended-Plus-Core"] then - util.titanium_plate = "titanium-alloy" -else - util.titanium_plate = "titanium-plate" -end - -if mods["pyrawores"] then - util.titanium_processing = "titanium-mk01" -else - util.titanium_processing = "titanium-processing" -end - -function util.se6() - return mods["space-exploration"] and mods["space-exploration"] >= "0.6" -end - -util.cablesg = util.se6() and "electronic" or "cable" - -function get_setting(name) - if settings.startup[name] == nil then - return nil - end - return settings.startup[name].value -end - -allbypass = {} -if get_setting("bz-recipe-bypass") then - for recipe in string.gmatch(me.get_setting("bz-recipe-bypass"), '[^",%s]+') do - allbypass[recipe] = true - end -end - -function util.is_foundry() - return mods.bzfoundry2 and not me.get_setting("bzfoundry-minimal") -end - -function should_force(options) - return options and options.force -end - - -function bypass(recipe_name) - if me.bypass[recipe_name] then return true end - if allbypass[recipe_name] then return true end - if get_setting("bz-tabula-rasa") then return true end -end - -function util.fe_plus(sub) - if mods["FactorioExtended-Plus-"..sub] then - return true - end -end - -function util.k2assets() - if mods["Krastorio2Assets"] then - return "__Krastorio2Assets__" - end - return "__Krastorio2__/graphics" -end - --- check if a table contains a sought value -function util.contains(table, sought) - for i, value in pairs(table) do - if value == sought then - return true - end - end - return false -end - - --- se landfill --- params: ore, icon_size -function util.se_landfill(params) - if mods["space-exploration"] then - if not params.icon_size then params.icon_size = 64 end - local lname="landfill-"..params.ore - data:extend({ - { - type = "recipe", - icons = { - { icon = "__base__/graphics/icons/landfill.png", icon_size = 64, icon_mipmaps = 3 }, - { icon = "__"..me.name.."__/graphics/icons/"..params.ore..".png", icon_size = params.icon_size, scale = 0.33*64/params.icon_size}, - }, - energy_required = 1, - enabled=false, - name = lname, - category = "hard-recycling", - order = "z-b-"..params.ore, - subgroup = "terrain", - results = {{type="item", name="landfill", amount=1}}, - ingredients = {{type="item", name=params.ore, amount=50}}, - } - }) - util.add_unlock("se-recycling-facility", lname) - end -end - - --- k2 matter --- params: {k2matter}, k2baseicon , {icon} -function util.k2matter(params) - local matter = require("__Krastorio2__/prototypes/libraries/matter") - if mods["space-exploration"] then - params.k2matter.need_stabilizer = true - end - if not params.k2matter.minimum_conversion_quantity then - params.k2matter.minimum_conversion_quantity = 10 - end - if not data.raw.technology[params.k2matter.unlocked_by_technology] then - local icon = "" - if params.k2baseicon then - icon = util.k2assets().."/technologies/matter-"..params.k2baseicon..".png" - else - icon = util.k2assets().."/technologies/backgrounds/matter.png" - end - - data:extend( - { - { - type = "technology", - name = params.k2matter.unlocked_by_technology, - icons = - { - { - icon = icon, - icon_size = 256, - }, - params.icon, - }, - prerequisites = {"kr-matter-processing"}, - unit = - { - count = 350, - ingredients = mods["space-exploration"] and - { - {"automation-science-pack", 1}, - {"logistic-science-pack", 1}, - {"chemical-science-pack", 1}, - {"se-astronomic-science-pack-4", 1}, - {"se-energy-science-pack-4", 1}, - {"se-material-science-pack-4", 1}, - {"se-deep-space-science-pack-2", 1}, - {"se-kr-matter-science-pack-2", 1}, - } or - { - {"production-science-pack", 1}, - {"utility-science-pack", 1}, - {"kr-matter-tech-card", 1} - }, - time = 45, - }, - localised_name = {"technology-name.k2-conversion", {"item-name."..params.k2matter.item_name}}, - }, - }) - end - matter.make_recipes(params.k2matter) -end - - --- se matter --- params: ore, energy_required, quant_out, quant_in, icon_size, stream_out -function util.se_matter(params) - if mods["space-exploration"] > "0.6" then - if not params.quant_in then params.quant_in = params.quant_out end - if not params.icon_size then params.icon_size = 64 end - local fname = "matter-fusion-"..params.ore - local sedata = mods.Krastorio2 and "se-kr-matter-synthesis-data" or "se-fusion-test-data" - local sejunk = mods.Krastorio2 and "se-broken-data" or "se-junk-data" - data:extend({ - { - type = "recipe", - name = fname, - localised_name = {"recipe-name.se-matter-fusion-to", {"item-name."..params.ore}}, - category = "space-materialisation", - subgroup = "materialisation", - order = "a-b-z", - icons = { - {icon = "__space-exploration-graphics__/graphics/blank.png", - icon_size = 64, scale = 0.5}, - {icon = "__space-exploration-graphics__/graphics/icons/fluid/particle-stream.png", - icon_size = 64, scale = 0.33, shift = {8,-8}}, - {icon = "__"..util.me.name.."__/graphics/icons/"..params.ore..".png", - icon_size = params.icon_size, scale = 0.33 * 64/params.icon_size, shift={-8, 8}}, - {icon = "__space-exploration-graphics__/graphics/icons/transition-arrow.png", - icon_size = 64, scale = 0.5}, - }, - energy_required = params.energy_required, - enabled = false, - ingredients = { - {type="item", name=sedata, amount=1}, - {type="fluid", name="se-particle-stream", amount=50}, - {type="fluid", name="se-space-coolant-supercooled", amount=25}, - }, - results = { - {type="item", name=params.ore, amount=params.quant_out}, - {type="item", name="se-contaminated-scrap", amount=1}, - {type="item", name=sedata, amount=1, probability=.99}, - {type="item", name=sejunk, amount=1, probability=.01}, - {type="fluid", name="se-space-coolant-hot", amount=25, ignored_by_productivity=25}, - } - } - }) - util.add_unlock("se-space-matter-fusion", fname) - - if mods.Krastorio2 then - local lname = params.ore.."-to-particle-stream" - data:extend({ - enabled = false, - { - type = "recipe", - name = lname, - localised_name = {"recipe-name.se-kr-matter-liberation", {"item-name."..params.ore}}, - category = "space-materialisation", - subgroup = "advanced-particle-stream", - order = "a-b-z", - icons = { - {icon = "__space-exploration-graphics__/graphics/blank.png", - icon_size = 64, scale = 0.5}, - {icon = "__space-exploration-graphics__/graphics/icons/fluid/particle-stream.png", - icon_size = 64, scale = 0.33, shift = {-8,8}}, - {icon = "__"..util.me.name.."__/graphics/icons/"..params.ore..".png", - icon_size = params.icon_size, scale = 0.33 * 64/params.icon_size, shift={8, -8}}, - {icon = "__space-exploration-graphics__/graphics/icons/transition-arrow.png", - icon_size = 64, scale = 0.5}, - }, - energy_required = 30, - enabled = false, - ingredients = { - {type="item", name="se-kr-matter-liberation-data", amount=1}, - {type="item", name=params.ore, amount=params.quant_in}, - {type="fluid", name="se-particle-stream", amount=50}, - }, - results = { - {type="item", name="se-kr-matter-liberation-data", amount=1, probability=.99}, - {type="item", name=sejunk, amount=1, probability=.01}, - {type="fluid", name="se-particle-stream", amount=params.stream_out, ignored_by_productivity=50}, - } - } - }) - if not data.raw.technology["bz-advanced-stream-production"] then - data:extend({ - { - type = "technology", - name ="bz-advanced-stream-production", - localised_name = {"", {"technology-name.se-kr-advanced-stream-production"}, " 2"}, - icon = "__space-exploration-graphics__/graphics/technology/material-fabricator.png", - icon_size = 128, - effects = {}, - unit = { - count = 100, - time = 15, - ingredients = { - {"automation-science-pack", 1}, - {"logistic-science-pack", 1}, - {"chemical-science-pack", 1}, - {"se-rocket-science-pack", 1}, - {"space-science-pack", 1}, - {"production-science-pack", 1}, - {"utility-science-pack", 1}, - {"se-astronomic-science-pack-4", 1}, - {"se-energy-science-pack-4", 1}, - {"se-material-science-pack-4", 1}, - {"kr-matter-tech-card", 1}, - {"se-deep-space-science-pack-1", 1}, - } - - }, - prerequisites = {"se-kr-advanced-stream-production"}, - }, - }) - end - util.add_unlock("bz-advanced-stream-production", lname) - end - end -end - --- Set/override a technology's prerequisites -function util.set_prerequisite(technology_name, prerequisites) - local technology = data.raw.technology[technology_name] - if technology then - technology.prerequisites = {} - for i, prerequisite in pairs(prerequisites) do - if data.raw.technology[prerequisite] then - table.insert(technology.prerequisites, prerequisite) - end - end - end -end - --- Add a prerequisite to a given technology -function util.add_prerequisite(technology_name, prerequisite) - local technology = data.raw.technology[technology_name] - if technology and data.raw.technology[prerequisite] then - if technology.prerequisites then - for i, pre in pairs(technology.prerequisites) do - if pre == prerequisite then return end - end - table.insert(technology.prerequisites, prerequisite) - else - technology.prerequisites = {prerequisite} - end - end -end - --- Remove a prerequisite from a given technology -function util.remove_prerequisite(technology_name, prerequisite) - local technology = data.raw.technology[technology_name] - local index = -1 - if technology then - for i, prereq in pairs(technology.prerequisites) do - if prereq == prerequisite then - index = i - break - end - end - if index > -1 then - table.remove(technology.prerequisites, index) - end - end -end - - --- Add an effect to a given technology -function util.add_effect(technology_name, effect) - local technology = data.raw.technology[technology_name] - if technology then - if not technology.effects then technology.effects = {} end - if effect and effect.type == "unlock-recipe" then - if not data.raw.recipe[effect.recipe] then - return - end - table.insert(technology.effects, effect) - end - end -end - --- Add an effect to a given technology to unlock recipe -function util.add_unlock(technology_name, recipe) - util.add_effect(technology_name, {type="unlock-recipe", recipe=recipe}) -end - --- Check if a tech unlocks a recipe -function util.check_unlock(technology_name, recipe) - local technology = data.raw.technology[technology_name] - if technology and technology.effects then - for i, effect in pairs(technology.effects) do - if effect.type == "unlock-recipe" and effect.recipe == recipe_name then - return true - end - end - end - return false -end - - - --- remove recipe unlock effect from a given technology, multiple times if necessary -function util.remove_recipe_effect(technology_name, recipe_name) - local technology = data.raw.technology[technology_name] - local index = -1 - local cnt = 0 - if technology and technology.effects then - for i, effect in pairs(technology.effects) do - if effect.type == "unlock-recipe" and effect.recipe == recipe_name then - index = i - cnt = cnt + 1 - end - end - if index > -1 then - table.remove(technology.effects, index) - if cnt > 1 then -- not over yet, do it again - util.remove_recipe_effect(technology_name, recipe_name) - end - end - end -end - --- Set technology ingredients -function util.set_tech_recipe(technology_name, ingredients) - local technology = data.raw.technology[technology_name] - if technology then - technology.unit.ingredients = ingredients - end -end - -function util.set_enabled(recipe_name, enabled) - if data.raw.recipe[recipe_name] then - data.raw.recipe[recipe_name].enabled = enabled - end -end - -function util.set_hidden(recipe_name) - if data.raw.recipe[recipe_name] then - data.raw.recipe[recipe_name].hidden = true - end -end - --- Add a given quantity of ingredient to a given recipe -function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then - me.add_modified(recipe_name) - add_or_add_to_ingredient(data.raw.recipe[recipe_name], ingredient, quantity) - end -end - -function add_or_add_to_ingredient(recipe, ingredient, quantity) - if recipe ~= nil and recipe.ingredients ~= nil then - for i, existing in pairs(recipe.ingredients) do - if existing[1] == ingredient or existing.name == ingredient then - add_to_ingredient(recipe, ingredient, quantity) - return - end - end - table.insert(recipe.ingredients, {ingredient, quantity}) - end -end - --- Add a given quantity of ingredient to a given recipe -function util.add_ingredient(recipe_name, ingredient, quantity, options) - if not should_force(options) and bypass(recipe_name) then return end - local is_fluid = not not data.raw.fluid[ingredient] - if data.raw.recipe[recipe_name] and (data.raw.item[ingredient] or is_fluid) then - me.add_modified(recipe_name) - add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity, is_fluid) - end -end - -function add_ingredient(recipe, ingredient, quantity, is_fluid) - if recipe ~= nil and recipe.ingredients ~= nil then - for i, existing in pairs(recipe.ingredients) do - if existing[1] == ingredient or existing.name == ingredient then - return - end - end - if is_fluid then - table.insert(recipe.ingredients, {type="fluid", name=ingredient, amount=quantity}) - else - table.insert(recipe.ingredients, {type="item", name=ingredient, amount=quantity}) - end - end -end - --- Add a given ingredient prototype to a given recipe -function util.add_ingredient_raw(recipe_name, ingredient, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] and (data.raw.item[ingredient.name] or data.raw.item[ingredient[1]]) then - me.add_modified(recipe_name) - add_ingredient_raw(data.raw.recipe[recipe_name], ingredient) - end -end - -function add_ingredient_raw(recipe, ingredient) - if recipe ~= nil and recipe.ingredients ~= nil then - for i, existing in pairs(recipe.ingredients) do - if ( - (existing[1] and (existing[1] == ingredient[1] or existing[1] == ingredient.name)) or - (existing.name and (existing.name == ingredient[1] or existing.name == ingredient.name)) - ) then - return - end - end - table.insert(recipe.ingredients, ingredient) - end -end - --- Set an ingredient to a given quantity -function util.set_ingredient(recipe_name, ingredient, quantity, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then - me.add_modified(recipe_name) - set_ingredient(data.raw.recipe[recipe_name], ingredient, quantity) - end -end - -function set_ingredient(recipe, ingredient, quantity) - if recipe ~= nil and recipe.ingredients ~= nil then - for i, existing in pairs(recipe.ingredients) do - if existing[1] == ingredient then - existing[2] = quantity - return - elseif existing.name == ingredient then - existing.amount = quantity - existing.amount_min = nil - existing.amount_max = nil - return - end - end - table.insert(recipe.ingredients, {ingredient, quantity}) - end -end --- Add a given quantity of product to a given recipe. --- Only works for recipes with multiple products -function util.add_product(recipe_name, product, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] and - (data.raw.item[product.name] or data.raw.fluid[product.name]) then - add_product(data.raw.recipe[recipe_name], product) - end -end - -function add_product(recipe, product) - if recipe ~= nil then - if recipe.results == nil then - recipe.results = {} - end - table.insert(recipe.results, product) - end -end - --- Get the amount of the ingredient, will check base/normal not expensive -function util.get_ingredient_amount(recipe_name, ingredient_name) - local recipe = data.raw.recipe[recipe_name] - if recipe then - if recipe.ingredients then - for i, ingredient in pairs(recipe.ingredients) do - if ingredient[1] == ingredient_name then return ingredient[2] end - if ingredient.name == ingredient_name then return ingredient.amount end - end - end - return 1 - end - return 0 -end - --- Get the amount of the result, will check base/normal not expensive -function util.get_amount(recipe_name, product) - if not product then product = recipe_name end - local recipe = data.raw.recipe[recipe_name] - if recipe then - if recipe.results then - for i, result in pairs(recipe.results) do - if result[1] == product then return result[2] end - if result.name == product then return result.amount end - end - elseif recipe.result_count then - return recipe.result_count - end - return 1 - end - return 0 -end - --- Get the count of results -function util.get_result_count(recipe_name, product) - if not product then product = recipe_name end - local recipe = data.raw.recipe[recipe_name] - if recipe then - if recipe.results then - return #(recipe.results) - end - return 1 - end - return 0 -end - --- Replace one ingredient with another in a recipe --- Use amount to set an amount. If that amount is a multiplier instead of an exact amount, set multiply true. -function util.replace_ingredient(recipe_name, old, new, amount, multiply, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) then - me.add_modified(recipe_name) - replace_ingredient(data.raw.recipe[recipe_name], old, new, amount, multiply) - end -end - -function replace_ingredient(recipe, old, new, amount, multiply) - if recipe ~= nil and recipe.ingredients ~= nil then - for i, existing in pairs(recipe.ingredients) do - if existing[1] == new or existing.name == new then - return - end - end - for i, ingredient in pairs(recipe.ingredients) do - if ingredient.name == old then - ingredient.name = new - if amount then - if multiply then - ingredient.amount = amount * ingredient.amount - else - ingredient.amount = amount - end - end - end - if ingredient[1] == old then - ingredient[1] = new - if amount then - if multiply then - ingredient[2] = amount * ingredient[2] - else - ingredient[2] = amount - end - end - end - end - end -end - --- Remove an ingredient from a recipe -function util.remove_ingredient(recipe_name, old, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] then - me.add_modified(recipe_name) - remove_ingredient(data.raw.recipe[recipe_name], old) - end -end - -function remove_ingredient(recipe, old) - index = -1 - if recipe ~= nil and recipe.ingredients ~= nil then - for i, ingredient in pairs(recipe.ingredients) do - if ingredient.name == old or ingredient[1] == old then - index = i - break - end - end - if index > -1 then - table.remove(recipe.ingredients, index) - end - end -end - --- Replace an amount of a product, leaving at least 1 of old -function util.replace_some_product(recipe_name, old, old_amount, new, new_amount, options) - if not should_force(options) and bypass(recipe_name) then return end - local is_fluid = not not data.raw.fluid[new] -- NOTE CURRENTLY UNUSUED - if data.raw.recipe[recipe_name] and (data.raw.item[new] or is_fluid) then - me.add_modified(recipe_name) - replace_some_product(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid) - end -end - -function replace_some_product(recipe, old, old_amount, new, new_amount, is_fluid) - if recipe ~= nil then - if recipe.result == new then return end - if recipe.results then - for i, existing in pairs(recipe.results) do - if existing.name == new then - return - end - end - end - add_product(recipe, {type=is_fluid and "fluid" or "item", name=new, amount=new_amount}) - for i, product in pairs(recipe.results) do - if product.name == old then - product.amount = math.max(1, product.amount - old_amount) - end - end - end -end - --- Replace an amount of an ingredient in a recipe. Keep at least 1 of old. -function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amount, options) - if not should_force(options) and bypass(recipe_name) then return end - local is_fluid = not not data.raw.fluid[new] - if data.raw.recipe[recipe_name] and (data.raw.item[new] or is_fluid) then - me.add_modified(recipe_name) - replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid) - end -end - -function replace_some_ingredient(recipe, old, old_amount, new, new_amount, is_fluid) - if recipe ~= nil and recipe.ingredients ~= nil then - for i, existing in pairs(recipe.ingredients) do - if existing[1] == new or existing.name == new then - return - end - end - for i, ingredient in pairs(recipe.ingredients) do - if ingredient.name == old then - ingredient.amount = math.max(1, ingredient.amount - old_amount) - end - if ingredient[1] == old then - ingredient[2] = math.max(1, ingredient[2] - old_amount) - end - end - add_ingredient(recipe, new, new_amount, is_fluid) - end -end - --- set the amount of a product. -function util.set_product_amount(recipe_name, product, amount, options) - if not should_force(options) and bypass(recipe_name) then return end - me.add_modified(recipe_name) - if data.raw.recipe[recipe_name] then - set_product_amount(data.raw.recipe[recipe_name], product, amount) - end -end - -function set_product_amount(recipe, product, amount) - if recipe then - if recipe.result_count then - recipe.result_count = amount - end - if recipe.results then - for i, result in pairs(recipe.results) do - if result.name == product then - if result.amount then - result.amount = amount - end - if result.amount_min ~= nil then - result.amount_min = nil - result.amount_max = nil - result.amount = amount - end - end - if result[1] == product then - result[2] = amount - end - end - end - if not recipe.results and not recipe.result_count then - -- implicit one item result - recipe.result_count = amount - end - end -end - --- multiply the cost, energy, and results of a recipe by a multiple -function util.multiply_recipe(recipe_name, multiple, options) - if not should_force(options) and bypass(recipe_name) then return end - me.add_modified(recipe_name) - if data.raw.recipe[recipe_name] then - multiply_recipe(data.raw.recipe[recipe_name], multiple) - end -end - -function multiply_recipe(recipe, multiple) - if recipe then - if recipe.energy_required then - recipe.energy_required = recipe.energy_required * multiple - end - if recipe.result_count then - recipe.result_count = recipe.result_count * multiple - end - if recipe.results then - for i, result in pairs(recipe.results) do - if result.name then - if result.amount then - result.amount = result.amount * multiple - end - if result.amount_min ~= nil then - result.amount_min = result.amount_min * multiple - result.amount_max = result.amount_max * multiple - end - if result.ignored_by_productivity then - result.ignored_by_productivity = result.ignored_by_productivity * multiple - end - end - if result[1] then - result[2] = result[2] * multiple - end - end - end - if not recipe.results and not recipe.result_count then - -- implicit one item result - recipe.result_count = multiple - end - if recipe.ingredients then - for i, ingredient in pairs(recipe.ingredients) do - if ingredient.name then - ingredient.amount = ingredient.amount * multiple - end - if ingredient[1] then - ingredient[2] = ingredient[2] * multiple - end - end - end - end -end - --- Returns true if a recipe has an ingredient -function util.has_ingredient(recipe_name, ingredient) - return data.raw.recipe[recipe_name] and - has_ingredient(data.raw.recipe[recipe_name], ingredient) -end - -function has_ingredient(recipe, ingredient) - if recipe ~= nil and recipe.ingredients ~= nil then - for i, existing in pairs(recipe.ingredients) do - if existing[1] == ingredient or existing.name == ingredient then - return true - end - end - end - return false -end - --- Remove a product from a recipe, WILL NOT remove the only product -function util.remove_product(recipe_name, old, options) - if not should_force(options) and bypass(recipe_name) then return end - me.add_modified(recipe_name) - if data.raw.recipe[recipe_name] then - remove_product(data.raw.recipe[recipe_name], old) - end -end - -function remove_product(recipe, old) - index = -1 - if recipe ~= nil and recipe.results ~= nil then - for i, result in pairs(recipe.results) do - if result.name == old or result[1] == old then - index = i - break - end - end - if index > -1 then - table.remove(recipe.results, index) - end - end -end - -function util.set_main_product(recipe_name, product, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] then - set_main_product(data.raw.recipe[recipe_name], product) - end -end - -function set_main_product(recipe, product) - if recipe then - recipe.main_product = product - end -end - --- Replace one product with another in a recipe -function util.replace_product(recipe_name, old, new, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] then - replace_product(data.raw.recipe[recipe_name], old, new) - end -end - -function replace_product(recipe, old, new) - if recipe then - if recipe.main_product == old then - recipe.main_product = new - end - if recipe.result == old then - recipe.result = new - return - end - if recipe.results then - for i, result in pairs(recipe.results) do - if result.name == old then result.name = new end - if result[1] == old then result[1] = new end - end - end - end -end - --- Remove an element of type t and name from data.raw -function util.remove_raw(t, name) - if not data.raw[t] then - log(t.." not found in data.raw") - return - end - if data.raw[t][name] then - for i, elem in pairs(data.raw[t]) do - if elem.name == name then - data.raw[t][i] = nil - break - end - end - end -end - --- Set energy required -function util.set_recipe_time(recipe_name, time, options) - if not should_force(options) and bypass(recipe_name) then return end - me.add_modified(recipe_name) - if data.raw.recipe[recipe_name] then - set_recipe_time(data.raw.recipe[recipe_name], time) - end -end - -function set_recipe_time(recipe, time) - if recipe then - if recipe.energy_required then - recipe.energy_required = time - end - end -end - --- Multiply energy required -function util.multiply_time(recipe_name, factor, options) - if not should_force(options) and bypass(recipe_name) then return end - me.add_modified(recipe_name) - if data.raw.recipe[recipe_name] then - multiply_time(data.raw.recipe[recipe_name], factor) - end -end - -function multiply_time(recipe, factor) - if recipe then - if recipe.energy_required then - recipe.energy_required = recipe.energy_required * factor - end - end -end - --- Add to energy required -function util.add_time(recipe_name, amount, options) - if not should_force(options) and bypass(recipe_name) then return end - me.add_modified(recipe_name) - if data.raw.recipe[recipe_name] then - add_time(data.raw.recipe[recipe_name], amount) - end -end - -function add_time(recipe, amount) - if recipe then - if recipe.energy_required then - recipe.energy_required = recipe.energy_required + amount - end - end -end - --- Set recipe category -function util.set_category(recipe_name, category, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] and data.raw["recipe-category"][category] then - me.add_modified(recipe_name) - data.raw.recipe[recipe_name].category = category - end -end - --- Set recipe subgroup -function util.set_subgroup(recipe_name, subgroup, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] then - me.add_modified(recipe_name) - data.raw.recipe[recipe_name].subgroup = subgroup - end -end - --- Set item subgroup -function util.set_item_subgroup(item, subgroup, options) - if not should_force(options) and bypass(item) then return end -- imperfect, close enough for now? - if data.raw.item[item] and data.raw["item-subgroup"][subgroup] then - data.raw.item[item].subgroup = subgroup - end -end - -function util.add_icon(recipe_name, icon, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] then - me.add_modified(recipe_name) - if not (data.raw.recipe[recipe_name].icons and #(data.raw.recipe[recipe_name].icons) > 0) then - data.raw.recipe[recipe_name].icons = {} - if data.raw.recipe[recipe_name].icon then - data.raw.recipe[recipe_name].icons = {{ - icon=data.raw.recipe[recipe_name].icon, - icon_size=data.raw.recipe[recipe_name].icon_size, - icon_mipmaps=data.raw.recipe[recipe_name].icon_mipmaps, - }} - data.raw.recipe[recipe_name].icon = nil - data.raw.recipe[recipe_name].icon_size = nil - end - end - table.insert(data.raw.recipe[recipe_name].icons, icon) - end -end - --- Set recipe icons -function util.set_icons(recipe_name, icons, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] then - me.add_modified(recipe_name) - data.raw.recipe[recipe_name].icons = icons - data.raw.recipe[recipe_name].icon = nil - data.raw.recipe[recipe_name].icon_size = nil - end -end - --- Set recipe icons -function util.set_item_icons(item_name, icons) - if data.raw.item[item_name] then - data.raw.item[item_name].icons = icons - data.raw.item[item_name].icon = nil - data.raw.item[item_name].icon_size = nil - end -end - --- Gets an item or fluid icon -function util.get_item_or_fluid_icon(name) - icon = "" - if data.raw.item[name] then - icon = data.raw.item[name].icon - if not icon then icon = data.raw.item[name].icons[1].icon end - elseif data.raw.fluid[name] then - icon = data.raw.fluid[name].icon - if not icon then icon = data.raw.fluid[name].icons[1].icon end - end - return icon -end - -function util.set_to_founding(recipe, options) - util.set_category(recipe, "founding", options) - util.set_subgroup(recipe, "foundry-intermediate", options) -end - --- Add crafting category to an entity -function util.add_crafting_category(entity_type, entity, category) - if data.raw[entity_type][entity] and data.raw["recipe-category"][category] then - for i, existing in pairs(data.raw[entity_type][entity].crafting_categories) do - if existing == category then - return - end - end - table.insert(data.raw[entity_type][entity].crafting_categories, category) - end -end - -function util.add_to_ingredient(recipe, ingredient, amount, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe] then - add_to_ingredient(data.raw.recipe[recipe], ingredient, amount) - end -end - -function add_to_ingredient(recipe, it, amount) - if recipe ~= nil and recipe.ingredients ~= nil then - for i, ingredient in pairs(recipe.ingredients) do - if ingredient.name == it then - ingredient.amount = ingredient.amount + amount - return - end - if ingredient[1] == it then - ingredient[2] = ingredient[2] + amount - return - end - end - end -end - -function util.add_to_product(recipe_name, product, amount, options) - if not should_force(options) and bypass(recipe_name) then return end - if data.raw.recipe[recipe_name] then - add_to_product(data.raw.recipe[recipe_name], product, amount) - end -end - -function add_to_product(recipe, product, amount) - if recipe ~= nil and recipe.results ~= nil then - if recipe.result == product then - recipe.result_count = recipe.result_count + amount - return - end - for i, result in pairs(recipe.results) do - if result.name == product then - result.amount = result.amount + amount - return - end - if result[1] == product then - result[2] = result[2] + amount - return - end - end - end -end - --- Adds a result to a mineable type -function util.add_minable_result(t, name, result) - if data.raw[t] and data.raw[t][name] and data.raw[t][name].minable then - if data.raw[t][name].minable.result and not data.raw[t][name].minable.results then - data.raw[t][name].minable.results = { - {data.raw[t][name].minable.result ,data.raw[t][name].minable.count}} - data.raw[t][name].minable.result = nil - data.raw[t][name].minable.result_count = nil - end - if data.raw[t][name].minable.results then - table.insert(data.raw[t][name].minable.results, result) - end - end -end - - -local function insert(nodes, node, value) - table.insert(node, value) -- store as parameter - if 21 == #node then - node = {""} - table.insert(nodes, node) - end - return node -end - -local function encode(data) - local node = {""} - local root = {node} - local n = string.len(data) - for i = 1,n,200 do - local value = string.sub(data, i, i+199) - node = insert(root, node, value) - end - while #root > 20 do - local nodes,node = {},{""} - for _, value in ipairs(root) do - node = insert(nodes, node, value) - end - root = nodes - end - if #root == 1 then root = root[1] else - table.insert(root, 1, "") -- no locale template - end - return #root < 3 and (root[2] or "") or root -end - -function decode(data) - if type(data) == "string" then return data end - local str = {} - for i = 2, #data do - str[i-1] = decode(data[i]) - end - return table.concat(str, "") -end - -function util.create_list() - if #me.list>0 then - if not data.raw.item[me.name.."-list"] then - data:extend({{ - type="item", - name=me.name.."-list", - localised_description = "", - enabled=false, - icon = "__core__/graphics/empty.png", - icon_size = 1, - stack_size = 1, - flags = {"hidden", "hide-from-bonus-gui"} - }}) - end - - local have = {} - local list = {} - for i, recipe in pairs(me.list) do - if not have[recipe] then - have[recipe] = true - table.insert(list, recipe) - end - end - - if #list>0 then - data.raw.item[me.name.."-list"].localised_description = - encode(decode(data.raw.item[me.name.."-list"].localised_description).."\n"..table.concat(list, "\n")) - end - end -end - -function util.remove_prior_unlocks(tech, recipe) - if data.raw.technology[tech].prerequisites then - for i, prerequisite in pairs(data.raw.technology[tech].prerequisites) do - remove_prior_unlocks(prerequisite, recipe) - end - end -end - -function remove_prior_unlocks(tech, recipe) - local technology = data.raw.technology[tech] - if technology then - util.remove_recipe_effect(tech, recipe) - if technology.prerequisites then - for i, prerequisite in pairs(technology.prerequisites) do - -- log("BZZZ removing prior unlocks for " .. tech ..", checking " .. prerequisite) -- Handy Debug :| - remove_prior_unlocks(prerequisite, recipe) - end - end - end -end - -function util.replace_ingredients_prior_to(tech, old, new, multiplier) - if not data.raw.technology[tech] then - log("Not replacing ingredient "..old.." with "..new.." because tech "..tech.." was not found") - return - end - util.remove_prior_unlocks(tech, old) - for i, recipe in pairs(data.raw.recipe) do - if (recipe.enabled and recipe.enabled ~= false) - and (not recipe.hidden or recipe.hidden == true) -- probably don't want to change hidden recipes - and string.sub(recipe.name, 1, 3) ~= 'se-' -- have to exlude SE in general :( - then - -- log("BZZZ due to 'enabled' replacing " .. old .. " with " .. new .." in " .. recipe.name) -- Handy Debug :| - util.replace_ingredient(recipe.name, old, new, multiplier, true) - end - end - if data.raw.technology[tech].prerequisites then - for i, prerequisite in pairs(data.raw.technology[tech].prerequisites) do - replace_ingredients_prior_to(prerequisite, old, new, multiplier) - end - end -end - -function replace_ingredients_prior_to(tech, old, new, multiplier) - local technology = data.raw.technology[tech] - if technology then - if technology.effects then - for i, effect in pairs(technology.effects) do - if effect.type == "unlock-recipe" then - -- log("BZZZ replacing " .. old .. " with " .. new .." in " .. effect.recipe) -- Handy Debug :| - util.replace_ingredient(effect.recipe, old, new, multiplier, true) - end - end - end - if technology.prerequisites then - for i, prerequisite in pairs(technology.prerequisites) do - -- log("BZZZ checking " .. prerequisite) -- Handy Debug :| - replace_ingredients_prior_to(prerequisite, old, new, multiplier) - end - end - end -end - -function util.remove_all_recipe_effects(recipe_name) - for name, _ in pairs(data.raw.technology) do - util.remove_recipe_effect(name, recipe_name) - end -end - -function util.add_unlock_force(technology_name, recipe) - util.set_enabled(recipe, false) - util.remove_all_recipe_effects(recipe) - util.add_unlock(technology_name, recipe) -end - --- sum the products of a recipe -function util.sum_products(recipe_name) - -- this is going to end up approximate in some cases, integer division is probs fine - if data.raw.recipe[recipe_name] then - local recipe = data.raw.recipe[recipe_name] - if not recipe.results then return recipe.result_count end - local sum = 0 - for i, result in pairs(recipe.results) do - local amt = 0 - if result[2] then amt = result[2] - elseif result.amount then amt = result.amount - elseif result.amount_min then amt = (result.amount_min + result.amount_max)/2 - end - if result.probability then amt = amt * result.probability end - sum = sum + amt - end - return sum - end - return 0 -end - -function util.set_vtk_dcm_ingredients() - if mods["vtk-deep-core-mining"] then - local sum = util.sum_products("vtk-deepcore-mining-ore-chunk-refining") - log("setting vtk deepcore based on " .. serpent.dump(sum) .. " to " ..serpent.dump(sum*0.8)) - util.set_ingredient("vtk-deepcore-mining-ore-chunk-refining", "vtk-deepcore-mining-ore-chunk", sum * 0.8) - local sum = 1+util.sum_products("vtk-deepcore-mining-ore-chunk-refining-no-uranium") - log("setting vtk deepcore no uranium to " .. serpent.dump(sum)) - util.set_ingredient("vtk-deepcore-mining-ore-chunk-refining-no-uranium", "vtk-deepcore-mining-ore-chunk", sum) - end -end - -return util +local util = require("__bzlib__/data-util"); +util.initialize(me) +return util \ No newline at end of file diff --git a/bzgas2/info.json b/bzgas2/info.json index d6c756c..1309ecd 100644 --- a/bzgas2/info.json +++ b/bzgas2/info.json @@ -8,6 +8,7 @@ "homepage": "https://discord.gg/ufvFUJtVwk", "dependencies": [ "base >= 2.0.0", + "bzlib", "? bzfoundry2 >= 2.0.0", "? bztitanium2 >= 2.0.26", "? bzlead2 >= 2.0.29", From bc7e3c78af54f47b6f82cf6d81e6965c50d9550d Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Wed, 11 Mar 2026 22:05:34 +0100 Subject: [PATCH 15/15] 2.1.0 --- bzgas2/changelog.txt | 5 +++++ bzgas2/info.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bzgas2/changelog.txt b/bzgas2/changelog.txt index 98de4c9..8669d83 100644 --- a/bzgas2/changelog.txt +++ b/bzgas2/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 2.1.0 +Date: 11.03.2026 + Changes: + - Switch to bzlib - Please install the new dependency +--------------------------------------------------------------------------------------------------- Version: 2.0.5 Date: 10.12.2025 Bug Fixes: diff --git a/bzgas2/info.json b/bzgas2/info.json index 1309ecd..c0e9b71 100644 --- a/bzgas2/info.json +++ b/bzgas2/info.json @@ -1,6 +1,6 @@ { "name": "bzgas2", - "version": "2.0.5", + "version": "2.1.0", "factorio_version": "2.0", "title": "Natural Gas", "description": "Adds a natural gas resource, along with early game plastic.",