From 9be9a1e545bc5e77143f8e2382355b8876d9ba6e Mon Sep 17 00:00:00 2001 From: Brevven Date: Thu, 16 Jan 2025 14:50:14 -0800 Subject: [PATCH] up --- control-util.lua | 6 +++-- data-util.lua | 67 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 63 insertions(+), 10 deletions(-) diff --git a/control-util.lua b/control-util.lua index d744561..ef04e99 100644 --- a/control-util.lua +++ b/control-util.lua @@ -147,8 +147,10 @@ function regenerate_ore(event) for w in event.parameters:gmatch("%S+") do table.insert(params, w) end if #params == 1 and params[1] == "all" then for _, resource in pairs(me.resources) do - game.print("Regenerating "..resource) - game.regenerate_entity(resource) + if prototypes.entity[resource] then + game.print("Regenerating "..resource) + game.regenerate_entity(resource) + end end return end diff --git a/data-util.lua b/data-util.lua index f5fe558..5f39a0d 100644 --- a/data-util.lua +++ b/data-util.lua @@ -118,6 +118,15 @@ function util.contains(table, sought) return false end +-- copies a recipe, giving the copy a new name +function util.copy_recipe(recipe_name, new_recipe_name) + if data.raw.recipe[recipe_name] then + new_recipe = futil.table.deepcopy(data.raw.recipe[recipe_name]) + new_recipe.name = new_recipe_name + data:extend({new_recipe}) + end +end + -- Add the gleba rock. If it exists, still add resource to mine from it function util.add_gleba_rock(resource, amount_min, amount_max) if (not data.raw.planet.gleba or @@ -369,6 +378,30 @@ function util.use_fluid_mining_final() util.remove_raw("technology", "uranium-mining") end + +-- Add vacuum if it hasn't been added yet +function util.add_vacuum() + if not data.raw.fluid.vacuum then + data:extend({ + { + type = "fluid", + name = "vacuum", + icons = { util.vacuum_icon, }, + visualization_color = util.vacuum_vis, + subgroup = "fluid", + order = "d[vacuum]", + default_temperature = 1500, + max_temperature = 2000, + gas_temperature = 0, + heat_capacity = "0.01kJ", + base_color = {0.9, 0.9, 0.9}, + flow_color = {0.8, 0.8, 0.9}, + auto_barrel = false, + }, + }) + end +end + -- If Hot metals mod is enabled, mark these metals as hot function util.add_hot_metals(metals) if HotMetals and HotMetals.items then @@ -1094,9 +1127,6 @@ function multiply_recipe(recipe, multiple) else recipe.energy_required = 0.5 * multiple -- 0.5 is factorio default end - if recipe.result_count then - recipe.result_count = recipe.result_count * multiple - end if recipe.results then for i, result in pairs(recipe.results) do if result.name then @@ -1113,10 +1143,22 @@ function multiply_recipe(recipe, multiple) end end end - if not recipe.results and not recipe.result_count then - -- implicit one item result - recipe.result_count = multiple - end + multiply_ingredients(recipe, multiple) + end +end + +-- multiply the ingredient cost of a recipe +function util.multiply_ingredients(recipe_name, multiple, options) + if not should_force(options) and bypass(recipe_name) then return end + if data.raw.recipe[recipe_name] then + me.add_modified(recipe_name) + prepare_redo_recycling(recipe_name) + multiply_ingredients(data.raw.recipe[recipe_name], multiple) + end +end + +function multiply_ingredients(recipe, multiple) + if recipe then if recipe.ingredients then for i, ingredient in pairs(recipe.ingredients) do if ingredient.name then @@ -1277,6 +1319,13 @@ function add_time(recipe, amount) end end +-- Set localised name +function util.set_localised_name(recipe_name, localised_name) + if data.raw.recipe[recipe_name] then + data.raw.recipe[recipe_name].localised_name = localised_name + end +end + -- Set recipe category function util.set_category(recipe_name, category, options) if not should_force(options) and bypass(recipe_name) then return end @@ -1467,12 +1516,14 @@ function util.add_minable_result(t, name, result) if data.raw[t] and data.raw[t][name] and data.raw[t][name].minable then if data.raw[t][name].minable.result and not data.raw[t][name].minable.results then data.raw[t][name].minable.results = { - {data.raw[t][name].minable.result ,data.raw[t][name].minable.count}} + util.item(data.raw[t][name].minable.result ,data.raw[t][name].minable.count)} data.raw[t][name].minable.result = nil data.raw[t][name].minable.result_count = nil end if data.raw[t][name].minable.results then table.insert(data.raw[t][name].minable.results, result) + else + data.raw[t][name].minable.results = {result} end end end