From 353d8cfed1bb50539a547a2e737a9183d66f22b7 Mon Sep 17 00:00:00 2001 From: Brevven Date: Wed, 1 Jan 2025 22:48:17 -0800 Subject: [PATCH] up --- control-util.lua | 6 ++---- data-util.lua | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/control-util.lua b/control-util.lua index 1c97f1b..d744561 100644 --- a/control-util.lua +++ b/control-util.lua @@ -122,6 +122,7 @@ function util.warptorio2_expansion_helper() end local usage_regenerate = [[ +Recommend saving the game before running this command. Usage: /bz-regenerate all or /bz-regenerate [ ] planet must be an internal name like nauvis @@ -130,10 +131,9 @@ or /bz-regenerate [ ] Regenerates ore patches. If frequency/size/richness are provided, the planet will use those settings from now on, as well. - Separate arguments with spaces, do not use < >, [ ], quotes or other symbols - This action can take a while for larger maps! - - Ores can sometimes overlap on regeneration. + - Ores can sometimes overlap on regeneration. This can sometimes hide ore patches. If none seem to be made for a resource, regenerate just that resource and tweak frequency/size. ]] function util.add_regenerate_command_handler() - log("I am here ".. util.me.name) script.on_event(defines.events.on_console_command, regenerate_ore) if not commands.commands[regenerate_command] then @@ -143,7 +143,6 @@ end function regenerate_ore(event) if event.command == regenerate_command then - game.print("I am trying ".. util.me.name) local params = {} for w in event.parameters:gmatch("%S+") do table.insert(params, w) end if #params == 1 and params[1] == "all" then @@ -159,7 +158,6 @@ function regenerate_ore(event) end local planet = params[1] for _, resource in pairs(me.resources) do - game.print("I am trying ".. util.me.name .. " " .. resource) if not game.surfaces[planet] then game.print("Could not find surface for "..planet..". May not exist, or may not yet be explored.") return diff --git a/data-util.lua b/data-util.lua index 6e3873f..de873bd 100644 --- a/data-util.lua +++ b/data-util.lua @@ -1144,6 +1144,28 @@ function util.add_crafting_category(entity_type, entity, category) end end +-- Add crafting category to all entities that have another category +function util.add_crafting_category_if(entity_type, category, other_category) + if data.raw[entity_type] and data.raw["recipe-category"][category] and data.raw["recipe-category"][other_category] then + for _, entity in pairs(data.raw[entity_type]) do + local found_good = false + local found_bad = false + for _, existing in pairs(entity.crafting_categories) do + if existing == other_category then + found_good = true + end + if existing == category then + found_bad = true + end + end + if found_good and not found_bad then + table.insert(entity.crafting_categories, category) + end + end + end +end + + function util.add_to_ingredient(recipe, ingredient, amount, options) if not should_force(options) and bypass(recipe_name) then return end if data.raw.recipe[recipe] then