From 4627a45cdb09def4e1f64398fb9113f2019f318c Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Wed, 10 Dec 2025 19:25:46 +0100 Subject: [PATCH] Cleanup --- bzgold2/data.lua | 3 - bzgold2/prototypes/rich-copper.lua | 374 ++++++++++++++--------------- 2 files changed, 184 insertions(+), 193 deletions(-) diff --git a/bzgold2/data.lua b/bzgold2/data.lua index 727db4a..a109d88 100644 --- a/bzgold2/data.lua +++ b/bzgold2/data.lua @@ -21,8 +21,5 @@ require("compatibility/248k") local util = require("data-util"); -if util.se6() then -end - -- Must be last util.create_list() diff --git a/bzgold2/prototypes/rich-copper.lua b/bzgold2/prototypes/rich-copper.lua index 1402ec7..4aae64d 100644 --- a/bzgold2/prototypes/rich-copper.lua +++ b/bzgold2/prototypes/rich-copper.lua @@ -4,154 +4,149 @@ local futil = require("util"); local util = require("data-util"); if util.me.platinum() or util.me.palladium() then -if mods.Krastorio2 then - -- no rich copper - local rm = futil.table.deepcopy(data.raw.recipe["kr-rare-metals"]) - rm.name = "rare-metals-1" - data:extend({rm}) - util.add_unlock("platinum-processing", "rare-metals-1") - util.add_unlock("palladium-processing", "rare-metals-1") - util.add_icon("rare-metals-1", {icon = "__bzgold2__/graphics/icons/platinum-powder.png", - icon_size = 64, scale = 0.25, shift = {-8,8}}) + if mods.Krastorio2 then + -- no rich copper + local rm = futil.table.deepcopy(data.raw.recipe["kr-rare-metals"]) + rm.name = "rare-metals-1" + data:extend({ rm }) + util.add_unlock("platinum-processing", "rare-metals-1") + util.add_unlock("palladium-processing", "rare-metals-1") + util.add_icon("rare-metals-1", { icon = "__bzgold2__/graphics/icons/platinum-powder.png", + icon_size = 64, scale = 0.25, shift = { -8, 8 } }) - util.multiply_recipe("kr-rare-metals", 2) - util.multiply_recipe("rare-metals-1", 2) - util.multiply_recipe("rare-metals-2", 2) + util.multiply_recipe("kr-rare-metals", 2) + util.multiply_recipe("rare-metals-1", 2) + util.multiply_recipe("rare-metals-2", 2) - util.set_main_product("kr-rare-metals", "kr-rare-metals") - util.set_product_amount("kr-rare-metals", "kr-rare-metals", 6) - util.set_main_product("rare-metals-1", "kr-rare-metals") - util.set_main_product("rare-metals-2", "kr-rare-metals") + util.set_main_product("kr-rare-metals", "kr-rare-metals") + util.set_product_amount("kr-rare-metals", "kr-rare-metals", 6) + util.set_main_product("rare-metals-1", "kr-rare-metals") + util.set_main_product("rare-metals-2", "kr-rare-metals") - - if util.me.platinum() and util.me.palladium() then - util.replace_some_product("rare-metals-1", "kr-rare-metals", 2, "platinum-powder", 2, {force=true}) - util.replace_some_product("rare-metals-1", "kr-rare-metals", 2, "palladium-powder", 2, {force=true}) - util.replace_some_product("rare-metals-2", "kr-rare-metals", 3, "platinum-powder", 3, {force=true}) - util.replace_some_product("rare-metals-2", "kr-rare-metals", 3, "palladium-powder", 3, {force=true}) - elseif util.me.platinum() then - util.replace_some_product("rare-metals-1", "kr-rare-metals", 3, "platinum-powder", 4, {force=true}) - util.replace_some_product("rare-metals-2", "kr-rare-metals", 6, "platinum-powder", 6, {force=true}) - elseif util.me.palladium() then - util.replace_some_product("rare-metals-1", "kr-rare-metals", 3, "palladium-powder", 4, {force=true}) - util.replace_some_product("rare-metals-2", "kr-rare-metals", 6, "palladium-powder", 6, {force=true}) - end -else - -local results = {} -if util.me.silver() and util.me.platinum() and util.me.palladium() then - results = { - {type="item", name="copper-plate", amount=1}, - {type="item", name="silver-ore", amount=1, probability=0.5}, - {type="item", name="platinum-powder", amount=1, probability=0.25}, - {type="item", name="palladium-powder", amount=1, probability=0.25}, - } -elseif util.me.silver() and util.me.platinum() then - results = { - {type="item", name="copper-plate", amount=1}, - {type="item", name="silver-ore", amount=1, probability=0.67}, - {type="item", name="platinum-powder", amount=1, probability=0.33}, - } -elseif util.me.silver() and util.me.palladium() then - results = { - {type="item", name="copper-plate", amount=1}, - {type="item", name="silver-ore", amount=1, probability=0.67}, - {type="item", name="palladium-powder", amount=1, probability=0.33}, - } -elseif util.me.platinum() and util.me.palladium() then - results = { - {type="item", name="copper-plate", amount=1}, - {type="item", name="platinum-powder", amount=1, probability=0.5}, - {type="item", name="palladium-powder", amount=1, probability=0.5}, - } -elseif util.me.platinum() then - results = { - {type="item", name="copper-plate", amount=2, probability = 0.75}, - {type="item", name="platinum-powder", amount=1, probability=0.5}, - } -elseif util.me.palladium() then - results = { - {type="item", name="copper-plate", amount=2, probability = 0.75}, - {type="item", name="palladium-powder", amount=1, probability=0.5}, - } -else -- should never happen - results = { - {type="item", name="copper-plate", amount=2}, - } -end - - -if data.raw.resource["copper-ore"] then - if mods["space-exploration"] then - -- decrease richness of copper a bit (ok if it stacks with aluminum) - data.raw.resource["copper-ore"].autoplace.richness_expression = - data.raw.resource["copper-ore"].autoplace.richness_expression .. "*(3/4)" + if util.me.platinum() and util.me.palladium() then + util.replace_some_product("rare-metals-1", "kr-rare-metals", 2, "platinum-powder", 2, { force = true }) + util.replace_some_product("rare-metals-1", "kr-rare-metals", 2, "palladium-powder", 2, { force = true }) + util.replace_some_product("rare-metals-2", "kr-rare-metals", 3, "platinum-powder", 3, { force = true }) + util.replace_some_product("rare-metals-2", "kr-rare-metals", 3, "palladium-powder", 3, { force = true }) + elseif util.me.platinum() then + util.replace_some_product("rare-metals-1", "kr-rare-metals", 3, "platinum-powder", 4, { force = true }) + util.replace_some_product("rare-metals-2", "kr-rare-metals", 6, "platinum-powder", 6, { force = true }) + elseif util.me.palladium() then + util.replace_some_product("rare-metals-1", "kr-rare-metals", 3, "palladium-powder", 4, { force = true }) + util.replace_some_product("rare-metals-2", "kr-rare-metals", 6, "palladium-powder", 6, { force = true }) + end else - log("Replacing vanilla copper-ore autoplace") - local resource_autoplace = require('resource-autoplace'); - data.raw.resource["copper-ore"].autoplace = resource_autoplace.resource_autoplace_settings{ - name = "copper-ore", - order = "b", - base_density = mods.bzaluminum2 and 3 or 4, - has_starting_area_placement = true, - regular_rq_factor_multiplier = 1.1, - starting_rq_factor_multiplier = 1.1, - candidate_spot_count = 22, - } - end -end -if util.se6() then - data:extend({ - { - type = "autoplace-control", - category = "resource", - name = "rich-copper-ore", - richness = true, - order = "zzzzzzzzzzz" - }, - }) -end + local results = {} + if util.me.silver() and util.me.platinum() and util.me.palladium() then + results = { + { type = "item", name = "copper-plate", amount = 1 }, + { type = "item", name = "silver-ore", amount = 1, probability = 0.5 }, + { type = "item", name = "platinum-powder", amount = 1, probability = 0.25 }, + { type = "item", name = "palladium-powder", amount = 1, probability = 0.25 }, + } + elseif util.me.silver() and util.me.platinum() then + results = { + { type = "item", name = "copper-plate", amount = 1 }, + { type = "item", name = "silver-ore", amount = 1, probability = 0.67 }, + { type = "item", name = "platinum-powder", amount = 1, probability = 0.33 }, + } + elseif util.me.silver() and util.me.palladium() then + results = { + { type = "item", name = "copper-plate", amount = 1 }, + { type = "item", name = "silver-ore", amount = 1, probability = 0.67 }, + { type = "item", name = "palladium-powder", amount = 1, probability = 0.33 }, + } + elseif util.me.platinum() and util.me.palladium() then + results = { + { type = "item", name = "copper-plate", amount = 1 }, + { type = "item", name = "platinum-powder", amount = 1, probability = 0.5 }, + { type = "item", name = "palladium-powder", amount = 1, probability = 0.5 }, + } + elseif util.me.platinum() then + results = { + { type = "item", name = "copper-plate", amount = 2, probability = 0.75 }, + { type = "item", name = "platinum-powder", amount = 1, probability = 0.5 }, + } + elseif util.me.palladium() then + results = { + { type = "item", name = "copper-plate", amount = 2, probability = 0.75 }, + { type = "item", name = "palladium-powder", amount = 1, probability = 0.5 }, + } + else + -- should never happen + results = { + { type = "item", name = "copper-plate", amount = 2 }, + } + end -data:extend({ - { - type = "resource", - name = "rich-copper-ore", - icon = "__bzgold2__/graphics/icons/rich-copper-ore.png", - icon_size = 64, icon_mipmaps = 4, - flags = {"placeable-neutral"}, - order="a-b-a", - map_color = {r=0.9, g=0.5, b=0.4}, - tree_removal_probability = 0.7, - tree_removal_max_distance = 32 * 32, - minable = - { - hardness = 1, - mining_particle = "copper-ore-particle", - mining_time = 1, - fluid_amount = 1, - required_fluid = "water", - result = "rich-copper-ore" - }, - collision_box = {{ -0.1, -0.1}, {0.1, 0.1}}, - selection_box = {{ -0.5, -0.5}, {0.5, 0.5}}, + if data.raw.resource["copper-ore"] then + if mods["space-exploration"] then + -- decrease richness of copper a bit (ok if it stacks with aluminum) + data.raw.resource["copper-ore"].autoplace.richness_expression = data.raw.resource["copper-ore"].autoplace.richness_expression .. "*(3/4)" + else + log("Replacing vanilla copper-ore autoplace") + local resource_autoplace = require('resource-autoplace'); + data.raw.resource["copper-ore"].autoplace = resource_autoplace.resource_autoplace_settings { + name = "copper-ore", + order = "b", + base_density = mods.bzaluminum2 and 3 or 4, + has_starting_area_placement = true, + regular_rq_factor_multiplier = 1.1, + starting_rq_factor_multiplier = 1.1, + candidate_spot_count = 22, + } + end + end - autoplace = resource_autoplace.resource_autoplace_settings{ - name = "rich-copper-ore", - autoplace_control_name = util.se6() and "rich-copper-ore" or "copper-ore", - order = "b-z", - base_density = 4, - base_spots_per_km2 = 1, - has_starting_area_placement = false, - regular_rq_factor_multiplier = 1, - starting_rq_factor_multiplier = 1, - }, - - stage_counts = {15000, 9500, 5500, 2900, 1300, 400, 150, 80}, - stages = + if util.se6() then + data:extend({ { - sheet = - { + type = "autoplace-control", + category = "resource", + name = "rich-copper-ore", + richness = true, + order = "zzzzzzzzzzz" + }, + }) + end + + data:extend({ + { + type = "resource", + name = "rich-copper-ore", + icon = "__bzgold2__/graphics/icons/rich-copper-ore.png", + icon_size = 64, icon_mipmaps = 4, + flags = { "placeable-neutral" }, + order = "a-b-a", + map_color = { r = 0.9, g = 0.5, b = 0.4 }, + tree_removal_probability = 0.7, + tree_removal_max_distance = 32 * 32, + minable = { + hardness = 1, + mining_particle = "copper-ore-particle", + mining_time = 1, + fluid_amount = 1, + required_fluid = "water", + result = "rich-copper-ore" + }, + collision_box = { { -0.1, -0.1 }, { 0.1, 0.1 } }, + selection_box = { { -0.5, -0.5 }, { 0.5, 0.5 } }, + + autoplace = resource_autoplace.resource_autoplace_settings { + name = "rich-copper-ore", + autoplace_control_name = util.se6() and "rich-copper-ore" or "copper-ore", + order = "b-z", + base_density = 4, + base_spots_per_km2 = 1, + has_starting_area_placement = false, + regular_rq_factor_multiplier = 1, + starting_rq_factor_multiplier = 1, + }, + + stage_counts = { 15000, 9500, 5500, 2900, 1300, 400, 150, 80 }, + stages = { + sheet = { filename = "__bzgold2__/graphics/entity/ores/hr-rich-copper-ore.png", priority = "extra-high", size = 128, @@ -159,57 +154,56 @@ data:extend({ variation_count = 8, scale = 0.5 } - }, - }, - { - type = "item", - name = "rich-copper-ore", - icon_size = 64, icon_mipmaps=4, - icon = "__bzgold2__/graphics/icons/rich-copper-ore.png", - pictures = { - {filename="__bzgold2__/graphics/icons/rich-copper-ore.png", size=64, scale=0.5}, - {filename="__bzgold2__/graphics/icons/rich-copper-ore-1.png", size=64, scale=0.5}, - {filename="__bzgold2__/graphics/icons/rich-copper-ore-2.png", size=64, scale=0.5}, - {filename="__bzgold2__/graphics/icons/rich-copper-ore-3.png", size=64, scale=0.5}, + }, }, - subgroup = "raw-resource", - order = "t-c-a", - stack_size = 50 - }, -}) + { + type = "item", + name = "rich-copper-ore", + icon_size = 64, icon_mipmaps = 4, + icon = "__bzgold2__/graphics/icons/rich-copper-ore.png", + pictures = { + { filename = "__bzgold2__/graphics/icons/rich-copper-ore.png", size = 64, scale = 0.5 }, + { filename = "__bzgold2__/graphics/icons/rich-copper-ore-1.png", size = 64, scale = 0.5 }, + { filename = "__bzgold2__/graphics/icons/rich-copper-ore-2.png", size = 64, scale = 0.5 }, + { filename = "__bzgold2__/graphics/icons/rich-copper-ore-3.png", size = 64, scale = 0.5 }, + }, + subgroup = "raw-resource", + order = "t-c-a", + stack_size = 50 + }, + }) + data:extend({ + { + type = "recipe", + name = "rich-copper", + localised_name = { "item-name.copper-plate" }, + category = "smelting", + main_product = "copper-plate", + order = "d[copper-plate]", + enabled = false, + icons = { + { icon = "__base__/graphics/icons/copper-plate.png", icon_size = 64, icon_mipmaps = 4 }, + { icon = "__bzgold2__/graphics/icons/rich-copper-ore.png", icon_size = 64, scale = 0.25, shift = { -8, 8 } }, + -- {icon = "__bzgold__/graphics/icons/silver-ore.png", icon_size = 128, scale=0.125, shift = {8,8}}, + -- {icon = "__bzgold__/graphics/icons/platinum-powder.png", icon_size = 64, scale=0.25, shift = {8,-8}}, + -- {icon = "__bzgold__/graphics/icons/palladium-powder.png", icon_size = 64, scale=0.25, shift = {-8,-8}}, + }, + energy_required = 6.4, + ingredients = { { type = "item", name = "rich-copper-ore", amount = 2 } }, + results = results, + }, + }) + util.add_unlock("platinum-processing", "rich-copper") + util.add_unlock("palladium-processing", "rich-copper") -data:extend({ - { - type = "recipe", - name = "rich-copper", - localised_name = {"item-name.copper-plate"}, - category = "smelting", - main_product = "copper-plate", - order = "d[copper-plate]", - enabled = false, - icons = { - {icon = "__base__/graphics/icons/copper-plate.png", icon_size = 64, icon_mipmaps=4}, - {icon = "__bzgold2__/graphics/icons/rich-copper-ore.png", icon_size = 64, scale=0.25, shift = {-8,8}}, - -- {icon = "__bzgold__/graphics/icons/silver-ore.png", icon_size = 128, scale=0.125, shift = {8,8}}, - -- {icon = "__bzgold__/graphics/icons/platinum-powder.png", icon_size = 64, scale=0.25, shift = {8,-8}}, - -- {icon = "__bzgold__/graphics/icons/palladium-powder.png", icon_size = 64, scale=0.25, shift = {-8,-8}}, - }, - energy_required = 6.4, - ingredients = {{type="item", name="rich-copper-ore", amount=2}}, - results = results, - }, -}) -util.add_unlock("platinum-processing", "rich-copper") -util.add_unlock("palladium-processing", "rich-copper") - -if util.se6() then - se_resources["rich-copper-ore"] = { - order = "b-z-c", - has_starting_area_placement = false, - base_density = 4, - base_spots_per_km2 = 1, - } -end -end + if util.se6() then + se_resources["rich-copper-ore"] = { + order = "b-z-c", + has_starting_area_placement = false, + base_density = 4, + base_spots_per_km2 = 1, + } + end + end end