From cc2a28d007cab66e12531688e58bd4664e0d9bbc Mon Sep 17 00:00:00 2001 From: Brevven Date: Wed, 27 Jul 2022 17:36:19 -0700 Subject: [PATCH] fix bakelite requirements --- changelog.txt | 7 +++++++ data-final-fixes.lua | 8 ++++++-- data-util.lua | 40 +++++++++++++++++++++------------------- info.json | 2 +- prototypes/bakelite.lua | 2 +- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/changelog.txt b/changelog.txt index 2806029..ccfe685 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,11 @@ --------------------------------------------------------------------------------------------------- +Version: 0.0.10 +Date: 2022-07-28 + Fixes: + - SE/K2: Fix incorrect extreme quantity of bakelite needed. + Changes: + - Bakelite is now also created much faster in chemical plants. +--------------------------------------------------------------------------------------------------- Version: 0.0.9 Date: 2022-07-26 Localization: diff --git a/data-final-fixes.lua b/data-final-fixes.lua index ce3f115..e81c9ec 100644 --- a/data-final-fixes.lua +++ b/data-final-fixes.lua @@ -15,8 +15,12 @@ if data.raw.recipe["electronic-circuit-stone"] then util.set_hidden("electronic-circuit-stone") end -util.replace_ingredient("electronic-circuit", "wood", "bakelite") -util.replace_ingredient_add_to("electronic-circuit", "iron-plate", "bakelite") +-- electronic circuits should each require one bakelite +local amt = util.get_amount("electronic-circuit") +util.remove_ingredient("electronic-circuit", "wood") +util.remove_ingredient("electronic-circuit", "iron-plate") +util.remove_ingredient("electronic-circuit", "stone-tablet") +util.add_ingredient("electronic-circuit", "bakelite", amt) util.set_icons("electronic-circuit", nil) -- Vanilla burner phase tweaks -- green circuits after electronics diff --git a/data-util.lua b/data-util.lua index 630f4ee..d5573d0 100644 --- a/data-util.lua +++ b/data-util.lua @@ -282,27 +282,29 @@ function add_product(recipe, product) end end -function util.replace_ingredient_add_to(recipe_name, old, new) - if me.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_add_to(data.raw.recipe[recipe_name], old, new) - replace_ingredient_add_to(data.raw.recipe[recipe_name].normal, old, new) - replace_ingredient_add_to(data.raw.recipe[recipe_name].expensive, old, new) - end -end - -function replace_ingredient_add_to(recipe, old, new) - 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 - add_to_ingredient(recipe, new, existing[2] and existing[2] or existing.amount) - remove_ingredient(recipe, old) - return +-- 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.normal and recipe.normal.results then + for i, result in pairs(recipe.normal.results) do + if result[1] == product then return result[2] end + if result.name == product then return result.amount end end + elseif recipe.normal and recipe.normal.result_count then + return recipe.normal.result_count + elseif 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 - replace_ingredient(recipe, old, new) - end + return 1 + end + return 0 end -- Replace one ingredient with another in a recipe diff --git a/info.json b/info.json index 8332d40..591978c 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bzgas", - "version": "0.0.9", + "version": "0.0.10", "factorio_version": "1.1", "title": "Natural Gas", "author": "Brevven", diff --git a/prototypes/bakelite.lua b/prototypes/bakelite.lua index daee445..345aafb 100644 --- a/prototypes/bakelite.lua +++ b/prototypes/bakelite.lua @@ -25,7 +25,7 @@ data:extend({ {util.me.use_phenol() and "phenol" or "coal", 1}, {type="fluid", name="formaldehyde", amount=10} }, - energy_required = 6, + energy_required = 2, results = { {type="item", name="bakelite", amount = 2}, },