This commit is contained in:
Brevven 2025-01-01 22:48:17 -08:00
parent a2b6c83333
commit 353d8cfed1
2 changed files with 24 additions and 4 deletions

View file

@ -122,6 +122,7 @@ function util.warptorio2_expansion_helper()
end end
local usage_regenerate = [[ local usage_regenerate = [[
Recommend saving the game before running this command.
Usage: /bz-regenerate all Usage: /bz-regenerate all
or /bz-regenerate <planet> <resource> [<frequency> <size> <richness>] or /bz-regenerate <planet> <resource> [<frequency> <size> <richness>]
planet must be an internal name like nauvis planet must be an internal name like nauvis
@ -130,10 +131,9 @@ or /bz-regenerate <planet> <resource> [<frequency> <size> <richness>]
Regenerates ore patches. If frequency/size/richness are provided, the planet will use those settings from now on, as well. 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 - Separate arguments with spaces, do not use < >, [ ], quotes or other symbols
- This action can take a while for larger maps! - 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() function util.add_regenerate_command_handler()
log("I am here ".. util.me.name)
script.on_event(defines.events.on_console_command, regenerate_ore) script.on_event(defines.events.on_console_command, regenerate_ore)
if not commands.commands[regenerate_command] then if not commands.commands[regenerate_command] then
@ -143,7 +143,6 @@ end
function regenerate_ore(event) function regenerate_ore(event)
if event.command == regenerate_command then if event.command == regenerate_command then
game.print("I am trying ".. util.me.name)
local params = {} local params = {}
for w in event.parameters:gmatch("%S+") do table.insert(params, w) end for w in event.parameters:gmatch("%S+") do table.insert(params, w) end
if #params == 1 and params[1] == "all" then if #params == 1 and params[1] == "all" then
@ -159,7 +158,6 @@ function regenerate_ore(event)
end end
local planet = params[1] local planet = params[1]
for _, resource in pairs(me.resources) do for _, resource in pairs(me.resources) do
game.print("I am trying ".. util.me.name .. " " .. resource)
if not game.surfaces[planet] then if not game.surfaces[planet] then
game.print("Could not find surface for "..planet..". May not exist, or may not yet be explored.") game.print("Could not find surface for "..planet..". May not exist, or may not yet be explored.")
return return

View file

@ -1144,6 +1144,28 @@ function util.add_crafting_category(entity_type, entity, category)
end end
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) function util.add_to_ingredient(recipe, ingredient, amount, options)
if not should_force(options) and bypass(recipe_name) then return end if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe] then if data.raw.recipe[recipe] then