razorgrass autoplace settings

This commit is contained in:
Brevven 2025-01-04 04:30:16 -08:00
parent 1f3258abd1
commit 51767552e5
3 changed files with 23 additions and 1 deletions

View file

@ -1,3 +1,23 @@
local util = require("control-util")
util.add_regenerate_command_handler()
script.on_configuration_changed(plant_fix)
function plant_fix()
if not script.active_mods["space-age"] then return end
local surface_name = "gleba"
for _, resource in pairs(me.resources) do
local map_gen_settings = game.surfaces[surface_name].map_gen_settings
if map_gen_settings.autoplace_controls[resource] == nil then
map_gen_settings.autoplace_controls[resource] = {}
end
if map_gen_settings.autoplace_settings.entity.settings[resource] == nil then
map_gen_settings.autoplace_settings.entity.settings[resource] = {}
end
game.surfaces[surface_name].map_gen_settings = map_gen_settings
end
end
script.on_event( defines.events.on_console_chat, function(event)
-- refresh recipes, in case of settings change
if event.message and event.message == "SiliconRecipes" and (not event.player_index or not game.players[event.player_index] or game.players[event.player_index].admin) then