From 41d2aab9b386441ae37325518e1265643aa3ab91 Mon Sep 17 00:00:00 2001 From: Brevven Date: Sun, 4 Dec 2022 01:04:22 -0800 Subject: [PATCH] updates --- README.md | 7 ++ changelog.txt | 14 ++- data-util.lua | 199 ++++++++++++++++++++++++++++++++++++- description.md | 33 ++++++ info.json | 2 +- locale/en/salt.cfg | 1 + map-gen-preset-updates.lua | 2 +- prototypes/chlorine.lua | 23 ++++- recipe-updates.lua | 9 +- 9 files changed, 278 insertions(+), 12 deletions(-) create mode 100644 description.md diff --git a/README.md b/README.md index e8c8da9..e8af027 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,13 @@ See changelog.txt - [Benjah-bmm27](https://commons.wikimedia.org/wiki/File:Vinyl-chloride-3D-vdW.png) (vinyl chloride icon) - [snouz](https://github.com/snouz) (logo inspiration) + ### Localization +### Testing +- Berkelear +- [Sakuro](https://github.com/sakuro) +- [Xynariz]() + + diff --git a/changelog.txt b/changelog.txt index 9b59108..08f5a42 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,9 +1,21 @@ --------------------------------------------------------------------------------------------------- +Version: 0.0.2 +Date: 2022-12-04 + Features: + - When used with Graphite & Diamonds, carbon fiber is enabled + Changes: + - Some recipe tweaks and changes, including an alternate ferric chloride recipe. + Fixes: + - Fix load issue when salt patches are turned off. +--------------------------------------------------------------------------------------------------- Version: 0.0.1 Date: 2022-08-05 Features: - - Alpha release. Adds salt, chlorine, and more. + - Alpha release. + - Adds salt, chlorine, hydrogen chloride, epoxy, printed circuit boards and more. + - Optionally adds ferric chloride and vinyl chloride - Compatible with Krastorio 2 - Compatible with Space Exploration + - Compatible with Bob's Electronics - Compatible with deadlock stacking/crating - Compatible with many other mods diff --git a/data-util.lua b/data-util.lua index 1aba726..3373bb2 100644 --- a/data-util.lua +++ b/data-util.lua @@ -1,6 +1,7 @@ -- 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 = {} @@ -89,6 +90,163 @@ function util.contains(table, sought) 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", + result = "landfill", + ingredients = {{params.ore, 50}}, + } + }) + util.add_unlock("se-recycling-facility", lname) + end +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 = { + {sedata, 1}, + {type="fluid", name="se-particle-stream", amount=50}, + {type="fluid", name="se-space-coolant-supercooled", amount=25}, + }, + results = { + {params.ore, params.quant_out}, + {"se-contaminated-scrap", 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, catalyst_amount=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 = { + {"se-kr-matter-liberation-data", 1}, + {params.ore, 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, catalyst_amount=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}, + {"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 + +-- Get the normal prototype for a recipe -- either .normal or the recipe itself +function util.get_normal(recipe_name) + if data.raw.recipe[recipe_name] then + recipe = data.raw.recipe[recipe_name] + if recipe.normal and recipe.normal.ingredients then + return recipe.normal + elseif recipe.ingredients then + return recipe + end + end +end + -- Set/override a technology's prerequisites function util.set_prerequisite(technology_name, prerequisites) local technology = data.raw.technology[technology_name] @@ -107,6 +265,9 @@ 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} @@ -772,9 +933,9 @@ function util.set_item_icons(item_name, icons) end end -function util.set_to_founding(recipe) - util.set_category(recipe, "founding") - util.set_subgroup(recipe, "foundry-intermediate") +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 @@ -1001,4 +1162,36 @@ function util.add_unlock_force(technology_name, 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 diff --git a/description.md b/description.md new file mode 100644 index 0000000..71e358c --- /dev/null +++ b/description.md @@ -0,0 +1,33 @@ +"Saying nothing... sometimes says the most" - *Emily Dickinson* + +---- + +Adds salt, chlorine, and other compounds to the game. Changes advanced circuit production and several other things. + +This mod adds more complexity to a vanailla factorio game. It pairs well with any other BZ mods, including [the electronics modpack](https://mods.factorio.com/mod/bzbelectronics). As always, the more BZ mods you add the more complex the game will become. + +Supported compatible mods: + +- Space Exploration & AAI +- Krastorio 2 +- Bob's electronics +- Deadlock stacking, crating + +Coming soon: RSO +Coming soon: 248k +Coming soon: FE+, 5Dim's, ModMash, etc. + +Many other mods are compatible but not yet fully supported. Suggestions always appreciated! + + +---- +Special thanks to + +- The community, for all the suggestions, feedback, and bug reports! +- [snouz](https://mods.factorio.com/user/snouz) (thumbnail style) + +Thanks for testing + +- Berkelear +- [Sakuro](https://mods.factorio.com/user/sakuro) +- [Xynariz](https://mods.factorio.com/user/Xynariz) diff --git a/info.json b/info.json index 8a0c005..d322afe 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bzchlorine", - "version": "0.0.1", + "version": "0.0.2", "factorio_version": "1.1", "title": "Salt & Chlorine", "author": "Brevven", diff --git a/locale/en/salt.cfg b/locale/en/salt.cfg index 03daf6f..8f7fb8d 100644 --- a/locale/en/salt.cfg +++ b/locale/en/salt.cfg @@ -12,6 +12,7 @@ pcb-substrate=__ITEM__pcb__ Substrate [item-description] pcb=Printed circuit board +pcb-substrate=A board to etch circuits onto [fluid-name] chlorine=Chlorine diff --git a/map-gen-preset-updates.lua b/map-gen-preset-updates.lua index 57986bd..f8220df 100644 --- a/map-gen-preset-updates.lua +++ b/map-gen-preset-updates.lua @@ -1,4 +1,4 @@ -if data.raw["map-gen-presets"] and data.raw["map-gen-presets"].default then +if data.raw["autoplace-control"]["salt"] and data.raw["map-gen-presets"] and data.raw["map-gen-presets"].default then for name, preset in pairs(data.raw["map-gen-presets"].default) do if type(preset) == "table" and preset.basic_settings and diff --git a/prototypes/chlorine.lua b/prototypes/chlorine.lua index 0658aa0..dcf704d 100644 --- a/prototypes/chlorine.lua +++ b/prototypes/chlorine.lua @@ -109,6 +109,22 @@ data:extend({ category = "chemistry", energy_required = 3, }, + { + type = "recipe", + name = "ferric-chloride-hcl", + results = {{"ferric-chloride", 4}}, + icons = { + {icon = "__bzchlorine__/graphics/icons/ferric-chloride.png", icon_size=64, scale=1}, + {icon = "__bzchlorine__/graphics/icons/hcl.png", icon_size=128, scale=0.25, shift={8,-8}}, + }, + ingredients = { + {"iron-ore", 1}, + {type="fluid", name="hydrogen-chloride", amount=120}, + }, + enabled = false, + category = "chemistry", + energy_required = 3, + }, { type = "recipe", name = "vinyl-chloride", @@ -130,8 +146,9 @@ data:extend({ { type="technology", name="chlorine-processing", - icon = "__bzchlorine__/graphics/icons/chlorine.png", -- FIX - icon_size = 128, + icons = { + {icon = "__bzchlorine__/graphics/technology/salt-tech.png", icon_size = 256, tint={a=.75,r=1,b=1,g=1} }, + }, effects = { { type = "unlock-recipe", recipe = "chlorine" }, { type = "unlock-recipe", recipe = "hydrogen-chloride-salt" }, @@ -145,10 +162,12 @@ data:extend({ }, }) util.add_unlock("chlorine-processing", "ferric-chloride") +util.add_unlock("chlorine-processing", "ferric-chloride-hcl") util.add_unlock("fluid-handling", "chemical-plant") util.remove_recipe_effect("oil-processing", "chemical-plant") else util.add_unlock("kr-fluids-chemistry", "ferric-chloride") + util.add_unlock("kr-fluids-chemistry", "ferric-chloride-hcl") util.add_unlock("kr-fluids-chemistry", "hydrogen-chloride-salt") end diff --git a/recipe-updates.lua b/recipe-updates.lua index 00aa0a1..cd96c56 100644 --- a/recipe-updates.lua +++ b/recipe-updates.lua @@ -22,8 +22,6 @@ if util.me.more() then end - - util.replace_some_ingredient("shotgun-shell", "stone", 1, "salt", 1) util.add_ingredient("pumpjack", "salt", 10) util.add_ingredient("kr-mineral-water-pumpjack", "salt", 10) @@ -45,8 +43,7 @@ util.add_ingredient("se-steel-ingot", "salt", 2) util.add_ingredient("se-iridium-powder", "chlorine", 20) util.add_product("se-iridium-powder", {type="fluid", name="chlorine", amount=19, catalyst_amount=19}) - -util.replace_some_ingredient("se-vitamelange-bloom", "sand", 10, "salt", 2) +util.replace_some_ingredient("se-vitamelange-bloom", "sand", 10, "salt", 1) util.add_ingredient("se-nutrient-gel", "salt", 1) util.add_ingredient("se-vitalic-epoxy", "epoxy", 16) @@ -54,3 +51,7 @@ util.multiply_recipe("se-space-water", 10) util.replace_some_ingredient("se-space-water", "water", 10, "salt", 1) util.add_ingredient("se-bio-sludge-decontamination", "chlorine", 1) util.add_ingredient("se-bio-electrics-data", "salt", 1) + +util.add_ingredient("se-holmium-chloride", "hydrogen-chloride", 2) + +util.add_ingredient("shiveros_advanced_uranium_reprocessing", "salt", 1)