From 51767552e57ff990c262b6f65002823817e536f8 Mon Sep 17 00:00:00 2001 From: Brevven Date: Sat, 4 Jan 2025 04:30:16 -0800 Subject: [PATCH] razorgrass autoplace settings --- control.lua | 20 ++++++++++++++++++++ me.lua | 3 ++- prototypes/razorgrass.lua | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/control.lua b/control.lua index 9f5333c..348453d 100644 --- a/control.lua +++ b/control.lua @@ -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 diff --git a/me.lua b/me.lua index e120dbc..e6033b3 100644 --- a/me.lua +++ b/me.lua @@ -1,6 +1,7 @@ local me = {} me.name = "bzsilicon" -me.silicon_processing = mods["Krastorio2"] and "kr-silicon-processing" or "silicon-processing" +me.resources = {"razorgrass"} +me.silicon_processing = (mods and mods["Krastorio2"] and "kr-silicon-processing") or "silicon-processing" me.recipes = {"silica", "silicon", "optical-fiber", "silicon-wafer", "solar-cell", "gyro", "silicon-smelting-vulcanite"} function me.use_gyros() diff --git a/prototypes/razorgrass.lua b/prototypes/razorgrass.lua index 3c37308..8651106 100644 --- a/prototypes/razorgrass.lua +++ b/prototypes/razorgrass.lua @@ -3,6 +3,7 @@ local util = require("data-util") if mods["space-age"] then +data.raw.planet.gleba.map_gen_settings.autoplace_settings.entity.settings["razorgrass"] = {} local space_age_item_sounds = require("__space-age__.prototypes.item_sounds") local function razorgrass_variations() local variation_count = 8 --variation_count or 5