From abc26a8eba2c8a1f5484d12b9ef6341415c50f01 Mon Sep 17 00:00:00 2001 From: Brevven Date: Sat, 12 Feb 2022 00:04:18 -0800 Subject: [PATCH] minimal mode setting --- changelog.txt | 6 ++++++ data.lua | 14 ++++++++++---- foundry-updates.lua | 39 ++++++++++++++++++++++++++++----------- locale/en/foundry.cfg | 4 +++- me.lua | 4 ++++ prototypes/categories.lua | 5 +++++ prototypes/foundry.lua | 6 ------ settings.lua | 7 +++++++ 8 files changed, 63 insertions(+), 22 deletions(-) create mode 100644 prototypes/categories.lua diff --git a/changelog.txt b/changelog.txt index 88562ea..96806d6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,12 @@ --------------------------------------------------------------------------------------------------- Version: 0.0.12 Date: 2022-02-12 + Features: + - Minimal mode setting. Only visible and used for certain mods (like Aluminum). + Intended as a workaround due to the way required dependencies work in Factorio. + Disables foundry buildings and many recipe changes. Intended to allow people to opt out of + using Foundry buildings while still letting Foundry be a required dependency for certain + other mods (like Aluminum). Founding will happen in assemblers. Fixes: - Processed fuel works in foundries with K2 + AAI Industry both enabled, once again. - Refractory recipes: Productivity no longer applies to refractories diff --git a/data.lua b/data.lua index 82f8662..ad46555 100644 --- a/data.lua +++ b/data.lua @@ -1,4 +1,10 @@ -require("prototypes/coke") -require("prototypes/foundry") -require("prototypes/entity/foundry") -require("prototypes/entity/electric-foundry") +local util = require("data-util") + +require("prototypes/categories") + +if util.me.enable() then + require("prototypes/coke") + require("prototypes/foundry") + require("prototypes/entity/foundry") + require("prototypes/entity/electric-foundry") +end diff --git a/foundry-updates.lua b/foundry-updates.lua index 89d08f8..147fc2d 100644 --- a/foundry-updates.lua +++ b/foundry-updates.lua @@ -1,21 +1,38 @@ local util = require("data-util") -util.set_to_founding("steel-plate") -util.replace_some_ingredient("steel-plate", "iron-plate", 1, util.me.carbon(), 1) -util.multiply_time("steel-plate", 4/5) -util.add_prerequisite("steel-processing", "foundry") +if util.me.enable() then + util.set_to_founding("steel-plate") + util.replace_some_ingredient("steel-plate", "iron-plate", 1, util.me.carbon(), 1) + util.multiply_time("steel-plate", 4/5) + util.add_prerequisite("steel-processing", "foundry") -util.set_to_founding("tungsten-carbide") -util.add_ingredient("tungsten-carbide", util.me.carbon(), 1) + util.set_to_founding("tungsten-carbide") + util.add_ingredient("tungsten-carbide", util.me.carbon(), 1) -util.set_to_founding("silicon") -util.add_ingredient("silicon", util.me.carbon(), 1) + util.set_to_founding("silicon") + util.add_ingredient("silicon", util.me.carbon(), 1) -util.set_to_founding("cermet") -- from zirconium -util.set_to_founding("crucible") -- from graphite + util.set_to_founding("cermet") -- from zirconium + util.set_to_founding("crucible") -- from graphite +else + -- If we're not using Foundry buildings, add founding recipes to assemblers in vanilla, or furnaces in K2 + local sought = mods.Krastorio2 and "smelting" or "crafting" + log ("looking for "..sought) + for i, machine in pairs(data.raw["assembling-machine"]) do + log(serpent.dump(machine)) + for j, category in pairs(machine.crafting_categories) do + if category == sought then + log ("found "..category) + util.add_crafting_category("assembling-machine", machine.name, "founding") + break + end + end + end + util.add_crafting_category("assembling-machine", "inustrial-furnace", "founding") + util.add_crafting_category("assembling-machine", "kr-advanced-furnace", "founding") +end --- K2 for i, machine in pairs(util.me.get_other_machines()) do log("Allowing "..machine.." to handle founding") util.add_crafting_category("assembling-machine", machine, "founding") diff --git a/locale/en/foundry.cfg b/locale/en/foundry.cfg index d490a94..da47413 100644 --- a/locale/en/foundry.cfg +++ b/locale/en/foundry.cfg @@ -39,10 +39,12 @@ bzfoundry-smelt=Foundry can smelt bzfoundry-plates=Add refractory recipes (experimental) bzfoundry-hydrocarbon=Hydrocarbon for founding bzfoundry-other-machines=Other machines that can do founding +bzfoundry-minimal=Minimal mode (remove buildings) [mod-setting-description] bzfoundry-recipe-bypass=Skip modifying these recipes (comma-separated list). bzfoundry-smelt=If true, the foundry building can also handle raw ore smelting. bzfoundry-hydrocarbon=Which hydrocarbon to use for founding. The foundry building is also used for coking.\nIf [color=cyan]coke[/color], a coke item and recipe is added, if needed.\nIf [color=cyan]solid fuel[/color], an early but inefficient recipe is added.\nIf [color=cyan]coal[/color], that is used.\nIf [color=cyan]none[/color], no hydrocarbon is used in founding (not recommended). bzfoundry-other-machines=List of other "assembling-machine" entities that can do "founding" recipes. Eg. Krastorio2's "kr-advanced-furnace", or AAII's "industrial-furnace" (comma-separated list). -bzfoundry-plates=[color=orange]EXPERIMENTAL[/color] Ingredients, products, or anything might change.\nRequires "Silica & Silicon", "Zirconium", or "Graphite & Diamonds" mod.\nUsing one or more refractories, Foundries can increase output of plates.\nBe warned, these are complex recipes. +bzfoundry-plates=[color=orange]EXPERIMENTAL[/color] Ingredients, products, or anything might change.\nUsing one or more refractories, foundries can increase output of plates.\nBe warned, these are complex recipes. +bzfoundry-minimal=[color=yellow]Use with caution![/color]\nIntended as a workaround for Factorio's required mod dependency system. Disables foundry buildings and recipe changes that rely on them. Allows you to play without Foundry with Aluminum, while still letting Foundry be a required dependency with default mod settings. diff --git a/me.lua b/me.lua index f7e2be2..e861b39 100644 --- a/me.lua +++ b/me.lua @@ -10,6 +10,10 @@ function me.smelt() return me.get_setting("bzfoundry-smelt") end +function me.enable() + return not me.get_setting("bzfoundry-minimal") +end + function me.carbon() return me.get_setting("bzfoundry-hydrocarbon") end diff --git a/prototypes/categories.lua b/prototypes/categories.lua new file mode 100644 index 0000000..cc81889 --- /dev/null +++ b/prototypes/categories.lua @@ -0,0 +1,5 @@ +data:extend({ + { type = "recipe-category", name = "founding"}, + { type = "item-subgroup", name = "founding-machines", group = "production"}, + { type = "item-subgroup", name = "foundry-intermediate", group = "intermediate-products"}, +}) diff --git a/prototypes/foundry.lua b/prototypes/foundry.lua index 088c77b..df68976 100644 --- a/prototypes/foundry.lua +++ b/prototypes/foundry.lua @@ -1,11 +1,5 @@ local util = require("data-util") -data:extend({ - { type = "recipe-category", name = "founding"}, - { type = "item-subgroup", name = "founding-machines", group = "production"}, - { type = "item-subgroup", name = "foundry-intermediate", group = "intermediate-products"}, -}) - local foundry_ingredients = {{"stone-brick", 20}, {"iron-plate", 10}, {"copper-plate", 5}} if mods.bzlead then table.insert(foundry_ingredients, {"lead-plate", 8}) end if mods.Krastorio2 or mods["aai-industry"] then diff --git a/settings.lua b/settings.lua index 1b94c30..8ba6427 100644 --- a/settings.lua +++ b/settings.lua @@ -32,4 +32,11 @@ data:extend({ default_value = "no", allowed_values = {"yes", "no"}, }, + { + type = "bool-setting", + name = "bzfoundry-minimal", + setting_type = "startup", + default_value = false, + hidden = not mods.bzaluminum + }, })