From 877e26ab3de1e27a9823599820707a32363edc8d Mon Sep 17 00:00:00 2001 From: Brevven Date: Sat, 4 Feb 2023 02:44:39 -0800 Subject: [PATCH] catalysis --- prototypes/catalyst.lua | 105 ++++++++++++++++++++++++++++++++++++ prototypes/oil-updates.lua | 47 ++++++++++++++++ prototypes/tech-updates.lua | 2 + 3 files changed, 154 insertions(+) create mode 100644 prototypes/catalyst.lua create mode 100644 prototypes/oil-updates.lua diff --git a/prototypes/catalyst.lua b/prototypes/catalyst.lua new file mode 100644 index 0000000..aefd9c7 --- /dev/null +++ b/prototypes/catalyst.lua @@ -0,0 +1,105 @@ +local util = require("data-util"); + +if util.me.catalysis() then + if util.me.palladium() or util.me.platinum() then + data:extend({ + { + type = "item", + name = "ptpd-catalyst", + icon = "__bzgold__/graphics/icons/ptpd-catalyst.png", + icon_size = 128, + pictures = { + {filename="__bzgold__/graphics/icons/ptpd-catalyst.png", size=128, scale=0.125}, + {filename="__bzgold__/graphics/icons/ptpd-catalyst-1.png", size=128, scale=0.125}, + {filename="__bzgold__/graphics/icons/ptpd-catalyst-2.png", size=128, scale=0.125}, + {filename="__bzgold__/graphics/icons/ptpd-catalyst-3.png", size=128, scale=0.125}, + }, + subgroup = "intermediate-product", + order = "b[catalyst]", + stack_size = util.get_stack_size(100), + }, + { + type = "technology", + name = "catalysis", + icons = { + { + icon = "__base__/graphics/technology/oil-processing.png", + icon_size = 256, + }, + }, + effects = {}, + unit = { + count = 100, time = 20, + ingredients = { + {"automation-science-pack", 1}, + {"logistic-science-pack", 1}, + {"chemical-science-pack", 1}, + {"production-science-pack", 1}, + }, + }, + prerequisites = {"production-science-pack"}, + order = "b-b", + }, + }) + end + + + local base = "stone" + if mods.bzaluminum then base = "alumina" + elseif mods.bzsilicon then base = "silica" + end + + local fluid = "sulfuric-acid" + if data.raw.fluid["hydrogen-chloride"] then fluid = "hydrogen-chloride" + end + + if util.me.palladium() then + data:extend({ + { + type = "recipe", + name = "pd-catalyst", + main_product = "ptpd-catalyst", + category = "chemistry", + order = "d[catalyst]", + enabled = false, + energy_required = 1.6, + ingredients = { + {base, 1}, + {"palladium-ingot", 1}, + {type="fluid", name=fluid, amount=100, catalyst_amount=100}, + }, + results = { + {"ptpd-catalyst", 1}, + {type="fluid", name=fluid, amount=90, catalyst_amount=90}, + {type="fluid", name="water", amount=10, catalyst_amount=9}, + }, + }, + }) + end + if util.me.platinum() then + data:extend({ + { + type = "recipe", + name = "pt-catalyst", + main_product = "ptpd-catalyst", + category = "chemistry", + order = "d[catalyst]", + enabled = false, + energy_required = 1.6, + ingredients = { + {base, 1}, + {"platinum-ingot", 1}, + {type="fluid", name=fluid, amount=100, catalyst_amount=100}, + }, + results = { + {"ptpd-catalyst", 1}, + {type="fluid", name=fluid, amount=90, catalyst_amount=90}, + {type="fluid", name="water", amount=10, catalyst_amount=9}, + }, + }, + }) + end + util.add_unlock("catalysis", "pt-catalyst") + util.add_unlock("catalysis", "pd-catalyst") +end + diff --git a/prototypes/oil-updates.lua b/prototypes/oil-updates.lua new file mode 100644 index 0000000..09ac408 --- /dev/null +++ b/prototypes/oil-updates.lua @@ -0,0 +1,47 @@ +local futil = require("util"); +local util = require("data-util"); + +local recipes_to_update = { + "heavy-oil-cracking", + "light-oil-cracking", + "solid-fuel-from-heavy-oil", + "solid-fuel-from-light-oil", + "solid-fuel-from-petroleum-gas", + "phenol-from-oil", +} + + +local prefix = "catalyzed-" +for i, recipe_name in pairs(recipes_to_update) do + -- create a copy of the recipe + local r = futil.table.deepcopy(data.raw.recipe[recipe_name]) + new_name = prefix..r.name + r.name = new_name + + if string.find(new_name, "cracking") then + r.localised_name = {"", {"recipe-name.catalyzed"}, " ", {"recipe-name."..recipe_name}} + else + local s + s, _ = string.find(recipe_name, "-from-") -- bit of a hack + r.main_product = string.sub(recipe_name, 1, s-1) + end + + -- copy should require 1 catalyst, and have 90% chance to return 1 catalyst + data:extend({r}) + util.add_ingredient(new_name, "ptpd-catalyst", 1, {force=true}) + util.add_product(new_name, {type="item", name="ptpd-catalyst", amount=1, + catalyst_amount=1, probability=.9}, {force=true}) + util.add_icon(new_name, {icon="__bzgold__/graphics/icons/ptpd-catalyst.png", + icon_size=128, scale=0.124, shift={8,-8}}) + + -- halve the time of the copy recipe + util.multiply_time(new_name, 0.5, {force=true}) + + -- copy should be unlocked by "catalysis" + util.add_unlock("catalysis", new_name) + + -- add 10 to the input oil ingredients of the basic recipe + for j, fluid in pairs({"heavy-oil", "light-oil", "petroleum-gas"}) do + util.add_to_ingredient(recipe_name, fluid, 10) + end +end diff --git a/prototypes/tech-updates.lua b/prototypes/tech-updates.lua index 4b147b8..3dd2c81 100644 --- a/prototypes/tech-updates.lua +++ b/prototypes/tech-updates.lua @@ -24,3 +24,5 @@ if mods.bzsilicon then util.add_unlock("advanced-electronics-2", "cpu") end util.add_unlock("advanced-electronics-2", "mainboard") + +util.add_unlock("coal-liquefaction", "catalysis")