mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-01-20 02:59:53 +02:00
Fix coin shop not being updated when mod setting changed. Change config parser to build helper table on load to avoid hard coded repeated stuff. Update changelog.
This commit is contained in:
parent
6b566e9e7a
commit
4e4f999e7e
@ -2,8 +2,12 @@
|
||||
Version: 2.0.3
|
||||
Date: 2024-10-13
|
||||
Major Features:
|
||||
- Return of the "coin shop" feature.
|
||||
- Return of the "coin shop" feature (including biters dropping coins).
|
||||
- Marking RSO as incompatible because I can't easily make it compatible.
|
||||
Bugfixes:
|
||||
- Fixed crash when player with shared spawn leaves and another player in the spawn menu selects that spawn.
|
||||
- Fixed crash when starting items has an entry with count 0.
|
||||
- Fixed not setting player back to the "Default" permissions group when they spawn.
|
||||
Info:
|
||||
- Updated comments in config file and scenario template to be more clear.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
@ -63,6 +63,14 @@ script.on_init(function(event)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- On Load - Only for setting up some table stuff that shouldn't change during gameplay!
|
||||
--------------------------------------------------------------------------------
|
||||
script.on_load(function()
|
||||
SetupOCFGModKeys()
|
||||
end)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- On Configuration Changed - Only runs when the mod configuration changes
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -396,7 +396,6 @@ OCFG = {
|
||||
enable_shared_chest = false,
|
||||
|
||||
-- Enable the coin shop GUI for players to buy items with coins.
|
||||
-- This makes biters drop coins on death.
|
||||
enable_coin_shop = false,
|
||||
},
|
||||
|
||||
@ -597,7 +596,7 @@ OCFG = {
|
||||
---@field respawn_cooldown_min number Respawn cooldown in minutes.
|
||||
---@field enable_shared_power boolean Enable shared power between bases. Creates a special power pole for cross surface connections.
|
||||
---@field enable_shared_chest boolean Enables a single shared chest using the native linked-chest entity in factorio.
|
||||
---@field enable_coin_shop boolean Enable the coin shop GUI for players to buy items with coins. This makes biters drop coins on death.
|
||||
---@field enable_coin_shop boolean Enable the coin shop GUI for players to buy items with coins.
|
||||
|
||||
---@class OarcConfigRegrowth
|
||||
---@field enable_regrowth boolean Cleans up unused chunks periodically. Helps keep map size down.
|
||||
|
@ -82,70 +82,22 @@ OCFG_KEYS =
|
||||
|
||||
---Easy reverse lookup for mod settings keys.
|
||||
---@type table<string, string>
|
||||
OCFG_MOD_KEYS =
|
||||
{
|
||||
["oarc-mod-welcome-msg-title"] = "server_info.welcome_msg_title",
|
||||
["oarc-mod-welcome-msg"] = "server_info.welcome_msg",
|
||||
["oarc-mod-discord-invite"] = "server_info.discord_invite",
|
||||
|
||||
["oarc-mod-enable-main-team"] = "gameplay.enable_main_team",
|
||||
["oarc-mod-enable-separate-teams"] = "gameplay.enable_separate_teams",
|
||||
-- STARTUP ["oarc-mod-default-allow-spawning-on-other-surfaces"] = " ["gameplay.enable_spawning_on_other_surfaces",
|
||||
["oarc-mod-allow-moats-around-spawns"] = "gameplay.allow_moats_around_spawns",
|
||||
["oarc-mod-enable-moat-bridging"] = "gameplay.enable_moat_bridging",
|
||||
["oarc-mod-minimum-distance-to-existing-chunks"] = "gameplay.minimum_distance_to_existing_chunks",
|
||||
["oarc-mod-near-spawn-distance"] = "gameplay.near_spawn_distance",
|
||||
["oarc-mod-far-spawn-distance"] = "gameplay.far_spawn_distance",
|
||||
|
||||
["oarc-mod-enable-buddy-spawn"] = "gameplay.enable_buddy_spawn",
|
||||
["oarc-mod-enable-offline-protection"] = "gameplay.enable_offline_protection",
|
||||
["oarc-mod-enable-shared-team-vision"] = "gameplay.enable_shared_team_vision",
|
||||
["oarc-mod-enable-shared-team-chat"] = "gameplay.enable_shared_team_chat",
|
||||
["oarc-mod-enable-shared-spawns"] = "gameplay.enable_shared_spawns",
|
||||
["oarc-mod-number-of-players-per-shared-spawn"] = "gameplay.number_of_players_per_shared_spawn",
|
||||
["oarc-mod-enable-friendly-fire"] = "gameplay.enable_friendly_fire",
|
||||
|
||||
-- STARTUP ["oarc-mod-main-force-name"] = "gameplay.main_force_name",
|
||||
["oarc-mod-default-surface"] = "gameplay.default_surface",
|
||||
["oarc-mod-enable-secondary-spawns"] = "gameplay.enable_secondary_spawns",
|
||||
|
||||
["oarc-mod-scale-resources-around-spawns"] = "gameplay.scale_resources_around_spawns",
|
||||
["oarc-mod-modified-enemy-spawning"] = "gameplay.modified_enemy_spawning",
|
||||
["oarc-mod-modified-enemy-easy-evo"] = "gameplay.modified_enemy_easy_evo",
|
||||
["oarc-mod-modified-enemy-medium-evo"] = "gameplay.modified_enemy_medium_evo",
|
||||
|
||||
["oarc-mod-minimum-online-time"] = "gameplay.minimum_online_time",
|
||||
["oarc-mod-respawn-cooldown-min"] = "gameplay.respawn_cooldown_min",
|
||||
["oarc-mod-enable-shared-power"] = "gameplay.enable_shared_power",
|
||||
["oarc-mod-enable-shared-chest"] = "gameplay.enable_shared_chest",
|
||||
["oarc-mod-enable-coin-shop"] = "gameplay.enable_coin_shop",
|
||||
|
||||
["oarc-mod-enable-regrowth"] = "regrowth.enable_regrowth",
|
||||
["oarc-mod-enable-world-eater"] = "regrowth.enable_world_eater",
|
||||
["oarc-mod-enable-abandoned-base-cleanup"] = "regrowth.enable_abandoned_base_cleanup",
|
||||
["oarc-mod-regrowth-cleanup-interval-min"] = "regrowth.cleanup_interval",
|
||||
|
||||
["oarc-mod-spawn-general-radius-tiles"] = "spawn_general.spawn_radius_tiles",
|
||||
["oarc-mod-spawn-general-moat-width-tiles"] = "spawn_general.moat_width_tiles",
|
||||
["oarc-mod-spawn-general-tree-width-tiles"] = "spawn_general.tree_width_tiles",
|
||||
["oarc-mod-spawn-general-enable-resources-circle-shape"] = "spawn_general.resources_shape",
|
||||
["oarc-mod-spawn-general-enable-force-grass"] = "spawn_general.force_grass",
|
||||
["oarc-mod-spawn-general-shape"] = "spawn_general.shape",
|
||||
|
||||
["oarc-mod-resource-placement-enabled"] = "resource_placement.enabled",
|
||||
["oarc-mod-resource-placement-distance-to-edge"] = "resource_placement.distance_to_edge",
|
||||
["oarc-mod-resource-placement-angle-offset"] = "resource_placement.angle_offset",
|
||||
["oarc-mod-resource-placement-angle-final"] = "resource_placement.angle_final",
|
||||
["oarc-mod-resource-placement-vertical-offset"] = "resource_placement.vertical_offset",
|
||||
["oarc-mod-resource-placement-horizontal-offset"] = "resource_placement.horizontal_offset",
|
||||
["oarc-mod-resource-placement-linear-spacing"] = "resource_placement.linear_spacing",
|
||||
["oarc-mod-resource-placement-size-multiplier"] = "resource_placement.size_multiplier",
|
||||
["oarc-mod-resource-placement-amount-multiplier"] = "resource_placement.amount_multiplier"
|
||||
}
|
||||
local OCFG_MOD_KEYS = {}
|
||||
|
||||
---Create the reverse lookup table.
|
||||
---@return nil
|
||||
function SetupOCFGModKeys()
|
||||
for key,entry in pairs(OCFG_KEYS) do
|
||||
if (entry.type ~= "header") and (entry.type ~= "subheader") then
|
||||
OCFG_MOD_KEYS[entry.mod_key] = key
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ValidateAndLoadConfig()
|
||||
|
||||
SetupOCFGModKeys()
|
||||
|
||||
-- Check that each of the OCFG_MOD_KEYS has a corresponding OCFG_KEYS entry.
|
||||
for mod_key,ocfg_key in pairs(OCFG_MOD_KEYS) do
|
||||
if (OCFG_KEYS[ocfg_key] == nil) then
|
||||
@ -371,6 +323,12 @@ function RuntimeModSettingChanged(event)
|
||||
ValidateSettings()
|
||||
ApplyRuntimeChanges(OCFG_MOD_KEYS[event.setting])
|
||||
end
|
||||
|
||||
--Exception for coin shop, update the GUI if the setting is changed
|
||||
if (event.setting == "oarc-mod-enable-coin-shop") then
|
||||
local new_value = global.ocfg.gameplay.enable_coin_shop
|
||||
AddRemoveOarcGuiTabForAllPlayers(OARC_ITEM_SHOP_TAB_NAME, settings.global[event.setting].value --[[@as boolean]], true)
|
||||
end
|
||||
end
|
||||
|
||||
---A probably quit stupid function to let me lookup and set the global.ocfg entries using a key table.
|
||||
|
@ -164,11 +164,6 @@ function SettingsControlsTabGuiClick(event)
|
||||
local entry = OCFG_KEYS[index]
|
||||
if (entry.type == "boolean") then
|
||||
settings.global[entry.mod_key] = { value = gui_elem.state }
|
||||
|
||||
--Exception for coin shop, update the GUI if the setting is changed
|
||||
if (entry.mod_key == "oarc-mod-enable-coin-shop") then
|
||||
AddRemoveOarcGuiTabForAllPlayers(OARC_ITEM_SHOP_TAB_NAME, gui_elem.state, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -10,4 +10,6 @@ end
|
||||
|
||||
if global.ocfg.coin_generation == nil then
|
||||
global.ocfg.coin_generation = table.deepcopy(OCFG.coin_generation)
|
||||
end
|
||||
end
|
||||
|
||||
SetupOCFGModKeys()
|
Loading…
x
Reference in New Issue
Block a user