diff --git a/changelog.txt b/changelog.txt index 0621323..7f172cf 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 0.4.0 +Date: 2021-02-27 + Features: + - New optional intermediates: Silicon wafer +--------------------------------------------------------------------------------------------------- Version: 0.3.7 Date: 2021-02-15 Changes: diff --git a/graphics/icons/silicon-wafer.png b/graphics/icons/silicon-wafer.png new file mode 100644 index 0000000..65bcc8c Binary files /dev/null and b/graphics/icons/silicon-wafer.png differ diff --git a/info.json b/info.json index e3cb46c..19b0565 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bzsilicon", - "version": "0.3.7", + "version": "0.4.0", "factorio_version": "1.1", "title": "Silica & Silicon", "author": "Brevven", diff --git a/locale/en/silicon.cfg b/locale/en/silicon.cfg index dfa2ef9..c681e48 100644 --- a/locale/en/silicon.cfg +++ b/locale/en/silicon.cfg @@ -1,16 +1,19 @@ [entity-name] silica=Silica silicon=Silicon +silicon-wafer=Silicon wafer optical-fiber=Optical Fiber [item-name] silica=Silica silicon=Silicon +silicon-wafer=Silicon wafer optical-fiber=Optical Fiber [item-description] silica=Can be used directly or processed further. silicon=Needed for various electrical and electronic applications +silicon-wafer=Use silicon in circuits optical-fiber=Cable used for fiber optics, including circuit network. [technology-name] @@ -27,3 +30,12 @@ fiber-optics=Optical fiber for circuit network silica=__ITEM__silica__ silicon=__ITEM__silicon__ optical-fiber=__ITEM__optical-fiber__ + + +# Settings + +[mod-setting-name] +bzsilicon-more-intermediates=Enable more intermediate recipes such as silicon wafers. More complex production chains. + +[mod-setting-description] +bzsilicon-more-intermediates=Optional in vanilla, Krastorio 2, etc. Requried for Bio Industries. diff --git a/prototypes/silicon-recipe.lua b/prototypes/silicon-recipe.lua index 9c1f5f6..6afba17 100644 --- a/prototypes/silicon-recipe.lua +++ b/prototypes/silicon-recipe.lua @@ -60,8 +60,14 @@ data:extend( { { type = "unlock-recipe", - recipe = "silicon" - } + recipe = "silicon", + }, + util.more_intermediates() and + { + type = "unlock-recipe", + recipe = "silicon-wafer", + } or nil, + }, unit = { @@ -78,3 +84,32 @@ data:extend( } or nil, } ) +if util.more_intermediates() then +data:extend({ + { + type = "item", + name = "silicon-wafer", + icon = "__bzsilicon__/graphics/icons/silicon-wafer.png", + icon_size = "64", + subgroup = "intermediate-product", + stack_size = util.get_stack_size(100), + }, + { + type = "recipe", + name = "silicon-wafer", + category = "crafting-with-fluid", + subgroup = "intermediate-product", + enabled = false, + energy_required = 20, + ingredients = (mods["Krastorio2"] and { + {type= "item", name="silicon", amount=20}, + {type= "fluid", name="hydrogen-chloride", amount=50}, + } or { + {type= "item", name="silicon", amount=20}, + {type= "fluid", name="sulfuric-acid", amount=50}, + }), + result = "silicon-wafer", + result_count = 10, + }, +}) +end diff --git a/recipe-updates.lua b/recipe-updates.lua index f650e56..4039671 100644 --- a/recipe-updates.lua +++ b/recipe-updates.lua @@ -5,15 +5,15 @@ if not mods["Krastorio2"] then util.add_ingredient("concrete", "silica", 25); util.add_prerequisite("concrete", "silica-processing") - util.replace_some_ingredient("processing-unit", "electronic-circuit", "silicon", 10) + util.replace_some_ingredient("processing-unit", "electronic-circuit", 10, "silicon-wafer", 5) util.add_prerequisite("advanced-electronics-2", util.silicon_processing) - util.replace_some_ingredient("solar-panel", "electronic-circuit", "silicon", 10) + util.replace_some_ingredient("solar-panel", "electronic-circuit", 10, "silicon", 10) util.add_prerequisite("solar-energy", "silicon-processing") - util.replace_ingredient("effectivity-module", "electronic-circuit", "silicon") - util.replace_ingredient("productivity-module", "electronic-circuit", "silicon") - util.replace_ingredient("speed-module", "electronic-circuit", "silicon") + util.replace_ingredient("effectivity-module", "electronic-circuit", "silicon-wafer") + util.replace_ingredient("productivity-module", "electronic-circuit", "silicon-wafer") + util.replace_ingredient("speed-module", "electronic-circuit", "silicon-wafer") util.add_prerequisite("modules", util.silicon_processing) else util.add_ingredient("concrete", "silica", 15); @@ -48,9 +48,15 @@ util.add_prerequisite("circuit-network", "fiber-optics") util.add_prerequisite("circuit-network", util.silicon_processing) if mods["Krastorio2"] then - util.add_prerequisite("kr-silicon-processing", "silica-processing") util.add_ingredient("biusart-lab", "optical-fiber", 10) util.add_ingredient("ai-core", "optical-fiber", 2) + + util.add_prerequisite(util.silicon_processing, "silica-processing") + if util.more_intermediates() then + util.add_effect(util.silicon_processing, {type = "unlock-recipe", recipe="silicon-wafer"}) + util.remove_ingredient("electronic-components", "silicon") + util.add_ingredient("electronic-components", "silicon-wafer", 1) + end end if mods["aai-signal-transimission"] then diff --git a/settings.lua b/settings.lua new file mode 100644 index 0000000..8864bb1 --- /dev/null +++ b/settings.lua @@ -0,0 +1,10 @@ +data:extend( +{ + { + type = "string-setting", + name = "bzsilicon-more-intermediates", + setting_type = "startup", + default_value = "no", + allowed_values = {"yes", "no"}, + }, +}) diff --git a/util.lua b/util.lua index b731c6b..b2f72cf 100644 --- a/util.lua +++ b/util.lua @@ -2,6 +2,17 @@ local util = {} util.silicon_processing = mods["Krastorio2"] and "kr-silicon-processing" or "silicon-processing" +function util.get_setting(name) + if settings.startup[name] == nil then + return nil + end + return settings.startup[name].value +end + +function util.more_intermediates() + return mods["Bio_Industries"] or util.get_setting("bzsilicon-more-intermediates") == "yes" +end + function util.get_stack_size(default) if mods["Krastorio2"] then size = tonumber(krastorio.general.getSafeSettingValue("kr-stack-size")) @@ -92,26 +103,32 @@ end -- Replace an amount of an ingredient in a recipe. Keep at least 1 of old. -function util.replace_some_ingredient(recipe_name, old, new, amount) - replace_some_ingredient(data.raw.recipe[recipe_name], old, new, amount) - replace_some_ingredient(data.raw.recipe[recipe_name].normal, old, new, amount) - replace_some_ingredient(data.raw.recipe[recipe_name].expensive, old, new, amount) +function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amount) + replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount) + replace_some_ingredient(data.raw.recipe[recipe_name].normal, old, old_amount, new, new_amount) + replace_some_ingredient(data.raw.recipe[recipe_name].expensive, old, old_amount, new, new_amount) end -function replace_some_ingredient(recipe, old, new, amount) +function replace_some_ingredient(recipe, old, old_amount, new, new_amount) if recipe ~= nil and recipe.ingredients ~= nil then for i, ingredient in pairs(recipe.ingredients) do - -- For final fixes if ingredient.name == old then - ingredient.amount = math.max(1, ingredient.amount - amount) + ingredient.amount = math.max(1, ingredient.amount - old_amount) end - -- For updates if ingredient[1] == old then - ingredient[2] = math.max(1, ingredient[2] - amount) + ingredient[2] = math.max(1, ingredient[2] - old_amount) end end - add_ingredient(recipe, new, amount) + add_ingredient(recipe, new, new_amount) end end +-- Add an effect to a given technology +function util.add_effect(technology_name, effect) + technology = data.raw.technology[technology_name] + if technology then + table.insert(technology.effects, effect) + end +end + return util