mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-01-03 22:52:25 +02:00
Saving GUI work for in game settings menu.
This commit is contained in:
parent
0ace14d001
commit
e278f216c0
@ -238,6 +238,7 @@ script.on_event(defines.events.on_gui_click, function(event)
|
||||
ServerInfoGuiClick(event)
|
||||
SpawnCtrlGuiClick(event)
|
||||
SettingsControlsTabGuiClick(event)
|
||||
SettingsSurfaceControlsTabGuiClick(event)
|
||||
end)
|
||||
|
||||
--- Called when LuaGuiElement checked state is changed (related to checkboxes and radio buttons).
|
||||
|
11
devplan.txt
11
devplan.txt
@ -1,6 +1,11 @@
|
||||
|
||||
ACTIVE ITEMS:
|
||||
|
||||
- Change regrowth to be list of surfaces indexed by surface name?
|
||||
- Add warning for modifying surface settings after gameplay has started
|
||||
- Ensure updates to regrowth surfaces don't cause errors (update indexes)
|
||||
- Make disable main team setting work (hide radio button)
|
||||
|
||||
|
||||
10. Tooltips for GUI elements in spawn menu options!
|
||||
13. Add regrowth settings GUI tab? Not sure how the other settings fit in with a dedicated regrowth tab? Need to be able to enable/disable other surfaces during runtime?
|
||||
@ -9,8 +14,6 @@ ACTIVE ITEMS:
|
||||
17. Support run time toggling of enable_shared_team_vision
|
||||
18. Support run time toggling of enable_friendly_fire
|
||||
19. Support run time toggling of main_force_name
|
||||
20. Force enable_world_eater to require enable_regrowth
|
||||
26. Fix all GUI styling (buttons outside of content)
|
||||
|
||||
27. Figure out how to reset player inventory on player reset to avoid extra items? (save and load items?)
|
||||
28.
|
||||
@ -51,4 +54,6 @@ Other Ideas, Not Committed:
|
||||
24. Remove the shared spawn separate GUI window?
|
||||
25. Redo DisplayBuddySpawnRequestMenu and DisplayBuddySpawnWaitMenu and move their events to the new event handlers
|
||||
23. Refresh the spawn controls GUI when player accepts/rejects
|
||||
15. Redo FindUngeneratedCoordinates to pick a random direction, and use the distance to get a starting point, instead of multiple tries.
|
||||
15. Redo FindUngeneratedCoordinates to pick a random direction, and use the distance to get a starting point, instead of multiple tries.
|
||||
26. Fix all GUI styling (buttons outside of content)
|
||||
20. Force enable_world_eater to require enable_regrowth
|
@ -6,10 +6,12 @@
|
||||
---@type table<string, OarcSettingsLookup>
|
||||
OCFG_KEYS =
|
||||
{
|
||||
["server_info.server_msg"] = {mod_key = "oarc-mod-server-msg" , ocfg_keys = {"server_info", "server_msg"}, type = "string"},
|
||||
["Server Info"] = {mod_key = "" , ocfg_keys = {""}, type = "header"},
|
||||
["server_info.welcome_msg_title"] = {mod_key = "oarc-mod-welcome-msg-title" , ocfg_keys = {"server_info", "welcome_msg_title"}, type = "string"},
|
||||
["server_info.server_msg"] = {mod_key = "oarc-mod-server-msg" , ocfg_keys = {"server_info", "server_msg"}, type = "string"},
|
||||
["server_info.welcome_msg"] = {mod_key = "oarc-mod-welcome-msg" , ocfg_keys = {"server_info", "welcome_msg"}, type = "string"},
|
||||
|
||||
["Gameplay"] = {mod_key = "" , ocfg_keys = {""}, type = "header"},
|
||||
["gameplay.enable_main_team"] = {mod_key = "oarc-mod-enable-main-team" , ocfg_keys = {"gameplay", "enable_main_team"}, type = "boolean"},
|
||||
["gameplay.enable_separate_teams"] = {mod_key = "oarc-mod-enable-separate-teams" , ocfg_keys = {"gameplay", "enable_separate_teams"}, type = "boolean"},
|
||||
["gameplay.enable_spawning_on_other_surfaces"] = {mod_key = "oarc-mod-enable-spawning-on-other-surfaces" , ocfg_keys = {"gameplay", "enable_spawning_on_other_surfaces"}, type = "boolean"},
|
||||
@ -36,6 +38,7 @@ OCFG_KEYS =
|
||||
["gameplay.minimum_online_time"] = {mod_key = "oarc-mod-minimum-online-time" , ocfg_keys = {"gameplay", "minimum_online_time"}, type = "integer"},
|
||||
["gameplay.respawn_cooldown_min"] = {mod_key = "oarc-mod-respawn-cooldown-min" , ocfg_keys = {"gameplay", "respawn_cooldown_min"}, type = "integer"},
|
||||
|
||||
["Regrowth"] = {mod_key = "" , ocfg_keys = {""}, type = "header"},
|
||||
["regrowth.enable_regrowth"] = {mod_key = "oarc-mod-enable-regrowth" , ocfg_keys = {"regrowth", "enable_regrowth"}, type = "boolean"},
|
||||
["regrowth.enable_world_eater"] = {mod_key = "oarc-mod-enable-world-eater" , ocfg_keys = {"regrowth", "enable_world_eater"}, type = "boolean"},
|
||||
["regrowth.enable_abandoned_base_cleanup"] = {mod_key = "oarc-mod-enable-abandoned-base-cleanup" , ocfg_keys = {"regrowth", "enable_abandoned_base_cleanup"}, type = "boolean"},
|
||||
@ -51,31 +54,35 @@ function ValidateAndLoadConfig()
|
||||
|
||||
GetScenarioOverrideSettings()
|
||||
|
||||
ValidateSettings()
|
||||
end
|
||||
|
||||
function ValidateSettings()
|
||||
|
||||
-- Validate enable_main_team and enable_separate_teams.
|
||||
-- Force enable_main_team if both are disabled.
|
||||
if (not global.ocfg.gameplay.enable_main_team and not global.ocfg.gameplay.enable_separate_teams) then
|
||||
log("Both main force and separate teams are disabled! Enabling main force. Please check your mod settings or config!")
|
||||
global.ocfg.gameplay.enable_main_team = true
|
||||
settings.global["oarc-mod-enable-main-team"] = { value = true }
|
||||
SendBroadcastMsg("Invalid setting! Both main force and separate teams are disabled! Enabling main force.")
|
||||
end
|
||||
|
||||
-- Validate minimum is less than maximums
|
||||
if (global.ocfg.gameplay.near_spawn_distance >= global.ocfg.gameplay.far_spawn_distance) then
|
||||
log("Near spawn min distance is greater than or equal to near spawn max distance! Please check your mod settings or config!")
|
||||
global.ocfg.gameplay.far_spawn_distance = global.ocfg.gameplay.near_spawn_distance + 1
|
||||
settings.global["oarc-mod-far-spawn-distance"] = { value = global.ocfg.gameplay.far_spawn_distance }
|
||||
SendBroadcastMsg("Invalid setting! Near spawn min distance is greater than or equal to near spawn max distance!")
|
||||
end
|
||||
|
||||
-- Validate that regrowth is enabled if world eater is enabled.
|
||||
if (global.ocfg.regrowth.enable_world_eater and not global.ocfg.regrowth.enable_regrowth) then
|
||||
log("World eater is enabled but regrowth is not! Disabling world eater. Please check your mod settings or config!")
|
||||
global.ocfg.regrowth.enable_world_eater = false
|
||||
settings.global["oarc-mod-enable-world-eater"] = { value = false }
|
||||
SendBroadcastMsg("Invalid setting! World eater is enabled but regrowth is not! Disabling world eater.")
|
||||
end
|
||||
|
||||
-- TODO: Vanilla spawn point are not implemented yet.
|
||||
-- Validate enable_shared_spawns and enable_buddy_spawn.
|
||||
-- if (global.ocfg.enable_vanilla_spawns) then
|
||||
-- global.ocfg.enable_buddy_spawn = false
|
||||
-- end
|
||||
|
||||
end
|
||||
|
||||
-- Read in the mod settings and copy them to the OARC_CFG table, overwriting the defaults in config.lua.
|
||||
@ -86,7 +93,9 @@ function CacheModSettings()
|
||||
-- Copy the global settings from the mod settings.
|
||||
-- Find the matching OARC setting and update it.
|
||||
for _,entry in pairs(OCFG_KEYS) do
|
||||
SetGlobalOarcConfigUsingKeyTable(entry.ocfg_keys, settings.global[entry.mod_key].value)
|
||||
if (entry.type ~= "header") then
|
||||
SetGlobalOarcConfigUsingKeyTable(entry.ocfg_keys, settings.global[entry.mod_key].value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -127,6 +136,8 @@ function RuntimeModSettingChanged(event)
|
||||
if (not found_setting) then
|
||||
error("Unknown oarc-mod setting changed: " .. event.setting)
|
||||
end
|
||||
|
||||
ValidateSettings()
|
||||
end
|
||||
|
||||
---A probably quit stupid function to let me lookup and set the global.ocfg entries using a key table.
|
||||
|
@ -5,10 +5,59 @@
|
||||
---@param player LuaPlayer
|
||||
---@return nil
|
||||
function CreateRegrowthControlsTab(tab_container, player)
|
||||
AddLabel(tab_container, nil, "test regrowth message my_label_style", my_label_style)
|
||||
AddLabel(tab_container, nil, "test regrowth message my_label_header_style", my_label_header_style)
|
||||
AddLabel(tab_container, nil, "test regrowth message my_label_header_grey_style", my_label_header_grey_style)
|
||||
AddLabel(tab_container, nil, "test regrowth message my_note_style", my_note_style)
|
||||
AddLabel(tab_container, nil, "test regrowth message my_warning_style", my_warning_style)
|
||||
AddLabel(tab_container, nil, "test regrowth message my_longer_label_style", my_longer_label_style)
|
||||
end
|
||||
|
||||
--- Create a table with 3 columns. Surface Name, Spawning Enabled, Regrowth Enabled
|
||||
local surface_table = tab_container.add {
|
||||
type = "table",
|
||||
name = "surface_table",
|
||||
column_count = 3,
|
||||
-- draw_horizontal_lines = true,
|
||||
-- draw_vertical_lines = true,
|
||||
-- draw_vertical_line_after_headers = true,
|
||||
style = "bordered_table",
|
||||
}
|
||||
|
||||
--- Add the header row
|
||||
AddLabel(surface_table, nil, "Surface", "caption_label")
|
||||
AddLabel(surface_table, nil, "Spawning Enabled", "caption_label")
|
||||
AddLabel(surface_table, nil, "Regrowth Enabled", "caption_label")
|
||||
|
||||
--- Add the rows
|
||||
for name, enabled in pairs(global.ocore.surfaces --[[@as table<string, boolean>]]) do
|
||||
AddLabel(surface_table, nil, name, my_label_style)
|
||||
|
||||
AddSurfaceCheckboxSetting(surface_table, name, "spawn_enabled", enabled)
|
||||
|
||||
-- AddSurfaceCheckboxSetting(surface_table, name, "regrowth_enabled", TableContains(global.rg.active_surfaces, name))
|
||||
|
||||
-- AddCheckbox(surface_table, nil, surface_name.."_spawn_enabled", surface.spawn_enabled)
|
||||
-- AddCheckbox(surface_table, nil, surface_name.."_regrowth_enabled", surface.regrowth_enabled)
|
||||
end
|
||||
|
||||
-- AddLabel(tab_container, nil, "test regrowth message my_label_style", my_label_style)
|
||||
-- AddLabel(tab_container, nil, "test regrowth message my_label_header_style", my_label_header_style)
|
||||
-- AddLabel(tab_container, nil, "test regrowth message my_label_header_grey_style", my_label_header_grey_style)
|
||||
-- AddLabel(tab_container, nil, "test regrowth message my_note_style", my_note_style)
|
||||
-- AddLabel(tab_container, nil, "test regrowth message my_warning_style", my_warning_style)
|
||||
-- AddLabel(tab_container, nil, "test regrowth message my_longer_label_style", my_longer_label_style)
|
||||
end
|
||||
|
||||
|
||||
|
||||
---Creates a checkbox setting for surface related settings.
|
||||
---@param parent LuaGuiElement
|
||||
---@param surface_name string
|
||||
---@param setting_name string
|
||||
---@param state boolean
|
||||
---@return nil
|
||||
function AddSurfaceCheckboxSetting(parent, surface_name, setting_name, state)
|
||||
parent.add{
|
||||
type = "checkbox",
|
||||
-- caption = { "mod-setting-name."..entry.mod_key },
|
||||
state = state,
|
||||
-- enabled = enabled,
|
||||
-- tooltip = { "mod-setting-description."..entry.mod_key },
|
||||
tags = { action = "oarc_surfaces_tab", setting = setting_name, surface = surface_name },
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -4,23 +4,82 @@
|
||||
---@param tab_container LuaGuiElement
|
||||
---@param player LuaPlayer
|
||||
function CreateSettingsControlsTab(tab_container, player)
|
||||
AddLabel(tab_container, nil, { "oarc-settings-tab-title" }, my_label_header_style)
|
||||
|
||||
if (player.admin) then
|
||||
AddLabel(tab_container, nil, { "oarc-settings-tab-admin-warning" }, my_warning_style)
|
||||
local label = AddLabel(tab_container, nil, { "oarc-settings-tab-admin-warning" }, my_warning_style)
|
||||
label.style.padding = 5
|
||||
end
|
||||
|
||||
local horizontal_flow = tab_container.add { type = "flow", direction = "horizontal", }
|
||||
|
||||
local scroll_pane_left = horizontal_flow.add {
|
||||
type = "scroll-pane",
|
||||
direction = "vertical",
|
||||
vertical_scroll_policy = "always",
|
||||
}
|
||||
scroll_pane_left.style.maximal_height = 500
|
||||
scroll_pane_left.style.padding = 5
|
||||
scroll_pane_left.style.right_margin = 2
|
||||
CreateModSettingsSection(scroll_pane_left, player)
|
||||
|
||||
local scroll_pane_right = horizontal_flow.add {
|
||||
type = "scroll-pane",
|
||||
direction = "vertical",
|
||||
vertical_scroll_policy = "always",
|
||||
}
|
||||
scroll_pane_right.style.maximal_height = 500
|
||||
scroll_pane_right.style.padding = 5
|
||||
scroll_pane_right.style.left_margin = 2
|
||||
CreateSurfaceSettingsSection(scroll_pane_right, player)
|
||||
end
|
||||
|
||||
---Create the content for the mod settings section
|
||||
---@param container LuaGuiElement
|
||||
---@param player LuaPlayer
|
||||
---@return nil
|
||||
function CreateModSettingsSection(container, player)
|
||||
AddLabel(container, nil, { "oarc-settings-tab-title" }, my_label_header2_style)
|
||||
|
||||
for index,entry in pairs(OCFG_KEYS) do
|
||||
if (entry.type == "boolean") then
|
||||
AddCheckboxSetting(tab_container, index, entry, player.admin)
|
||||
if (entry.type == "header") then
|
||||
AddSpacerLine(container)
|
||||
AddLabel(container, nil, index, "caption_label")
|
||||
elseif (entry.type == "boolean") then
|
||||
AddCheckboxSetting(container, index, entry, player.admin)
|
||||
elseif (entry.type == "string") then
|
||||
AddTextfieldSetting(tab_container, index, entry, player.admin)
|
||||
AddTextfieldSetting(container, index, entry, player.admin)
|
||||
elseif (entry.type == "integer") then
|
||||
AddIntegerSetting(tab_container, index, entry, player.admin)
|
||||
AddIntegerSetting(container, index, entry, player.admin)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---Create the content for the surface settings section
|
||||
---@param container LuaGuiElement
|
||||
---@param player LuaPlayer
|
||||
---@return nil
|
||||
function CreateSurfaceSettingsSection(container, player)
|
||||
AddLabel(container, nil, { "oarc-settings-tab-title-surface" }, my_label_header2_style)
|
||||
|
||||
--- Create a table with 3 columns. Surface Name, Spawning Enabled, Regrowth Enabled
|
||||
local surface_table = container.add {
|
||||
type = "table",
|
||||
name = "surface_table",
|
||||
column_count = 2,
|
||||
style = "bordered_table",
|
||||
}
|
||||
|
||||
--- Add the header row
|
||||
AddLabel(surface_table, nil, "Surface", "caption_label") ---TODO: localize
|
||||
AddLabel(surface_table, nil, "Spawning Enabled", "caption_label")
|
||||
|
||||
--- Add the rows
|
||||
for name, enabled in pairs(global.ocore.surfaces --[[@as table<string, boolean>]]) do
|
||||
AddLabel(surface_table, nil, name, my_label_style)
|
||||
AddSurfaceCheckboxSetting(surface_table, name, "spawn_enabled", enabled)
|
||||
end
|
||||
end
|
||||
|
||||
---Handles the click event for the tab used by AddOarcGuiTab
|
||||
---@param event EventData.on_gui_click
|
||||
---@return nil
|
||||
@ -29,15 +88,12 @@ function SettingsControlsTabGuiClick(event)
|
||||
|
||||
local gui_elem = event.element
|
||||
if (gui_elem.tags.action ~= "oarc_settings_tab") then return end
|
||||
local setting_name = gui_elem.tags.setting
|
||||
local index = gui_elem.tags.setting
|
||||
|
||||
for index,entry in pairs(OCFG_KEYS) do
|
||||
if (index == setting_name) then
|
||||
if (entry.type == "boolean") then
|
||||
SetGlobalOarcConfigUsingKeyTable(entry.ocfg_keys, gui_elem.state)
|
||||
settings.global[entry.mod_key] = { value = gui_elem.state }
|
||||
end
|
||||
end
|
||||
local entry = OCFG_KEYS[index]
|
||||
if (entry.type == "boolean") then
|
||||
SetGlobalOarcConfigUsingKeyTable(entry.ocfg_keys, gui_elem.state)
|
||||
settings.global[entry.mod_key] = { value = gui_elem.state }
|
||||
end
|
||||
end
|
||||
|
||||
@ -49,15 +105,12 @@ function SettingsControlsTabGuiTextChanged(event)
|
||||
|
||||
local gui_elem = event.element
|
||||
if (gui_elem.tags.action ~= "oarc_settings_tab") then return end
|
||||
local setting_name = gui_elem.tags.setting
|
||||
local index = gui_elem.tags.setting
|
||||
|
||||
for index,entry in pairs(OCFG_KEYS) do
|
||||
if (index == setting_name) then
|
||||
if (entry.type == "string") or (entry.type == "integer") then
|
||||
SetGlobalOarcConfigUsingKeyTable(entry.ocfg_keys, gui_elem.text)
|
||||
settings.global[entry.mod_key] = { value = gui_elem.text }
|
||||
end
|
||||
end
|
||||
local entry = OCFG_KEYS[index]
|
||||
if (entry.type == "string") or (entry.type == "integer") then
|
||||
SetGlobalOarcConfigUsingKeyTable(entry.ocfg_keys, gui_elem.text)
|
||||
settings.global[entry.mod_key] = { value = gui_elem.text }
|
||||
end
|
||||
end
|
||||
|
||||
@ -94,6 +147,10 @@ function AddTextfieldSetting(tab_container, index, entry, enabled)
|
||||
caption = { "mod-setting-name."..entry.mod_key },
|
||||
tooltip = { "mod-setting-description."..entry.mod_key },
|
||||
}
|
||||
local dragger = horizontal_flow.add {
|
||||
type = "empty-widget",
|
||||
}
|
||||
dragger.style.horizontally_stretchable = true
|
||||
horizontal_flow.add {
|
||||
type = "textfield",
|
||||
caption = { "mod-setting-name."..entry.mod_key },
|
||||
@ -120,7 +177,11 @@ function AddIntegerSetting(tab_container, index, entry, enabled)
|
||||
caption = { "mod-setting-name."..entry.mod_key },
|
||||
tooltip = { "mod-setting-description."..entry.mod_key },
|
||||
}
|
||||
horizontal_flow.add {
|
||||
local dragger = horizontal_flow.add {
|
||||
type = "empty-widget",
|
||||
}
|
||||
dragger.style.horizontally_stretchable = true
|
||||
local textfield = horizontal_flow.add {
|
||||
type = "textfield",
|
||||
numeric = true,
|
||||
caption = { "mod-setting-name."..entry.mod_key },
|
||||
@ -129,4 +190,42 @@ function AddIntegerSetting(tab_container, index, entry, enabled)
|
||||
tooltip = { "mod-setting-description."..entry.mod_key },
|
||||
tags = { action = "oarc_settings_tab", setting = index },
|
||||
}
|
||||
textfield.style.width = 100
|
||||
end
|
||||
|
||||
---Creates a checkbox setting for surface related settings.
|
||||
---@param parent LuaGuiElement
|
||||
---@param surface_name string
|
||||
---@param setting_name string
|
||||
---@param state boolean
|
||||
---@return nil
|
||||
function AddSurfaceCheckboxSetting(parent, surface_name, setting_name, state)
|
||||
parent.add{
|
||||
name = surface_name.."_"..setting_name,
|
||||
type = "checkbox",
|
||||
state = state,
|
||||
tags = { action = "oarc_settings_tab_surfaces", setting = setting_name, surface = surface_name },
|
||||
}
|
||||
end
|
||||
|
||||
---Handles the click event for surface related settings
|
||||
---@param event EventData.on_gui_click
|
||||
---@return nil
|
||||
function SettingsSurfaceControlsTabGuiClick(event)
|
||||
if not (event.element.valid) then return end
|
||||
|
||||
local gui_elem = event.element
|
||||
if (gui_elem.tags.action ~= "oarc_settings_tab_surfaces") then return end
|
||||
local setting_name = gui_elem.tags.setting
|
||||
local surface_name = gui_elem.tags.surface
|
||||
|
||||
if (setting_name == "spawn_enabled") then
|
||||
global.ocore.surfaces[surface_name] = gui_elem.state
|
||||
|
||||
if (#GetAllowedSurfaces() == 0) then
|
||||
log("Warning - GetAllowedSurfaces() - No surfaces found! Forcing default surface!")
|
||||
global.ocore.surfaces[global.ocfg.gameplay.default_surface] = true
|
||||
event.element.parent[global.ocfg.gameplay.default_surface.."_spawn_enabled"].state = true
|
||||
end
|
||||
end
|
||||
end
|
@ -30,6 +30,15 @@ my_label_header_style = {
|
||||
}
|
||||
---@type LuaStyle
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
my_label_header2_style = {
|
||||
single_line = false,
|
||||
font = "heading-2",
|
||||
font_color = {r=1,g=1,b=1},
|
||||
top_padding = 0,
|
||||
bottom_padding = 0
|
||||
}
|
||||
---@type LuaStyle
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
my_label_header_grey_style = {
|
||||
single_line = false,
|
||||
font = "heading-1",
|
||||
|
@ -224,6 +224,31 @@ function FYShuffle(T)
|
||||
return tReturn
|
||||
end
|
||||
|
||||
---Check if a table contains a value
|
||||
---@param table table
|
||||
---@param val any
|
||||
---@return boolean
|
||||
function TableContains(table, val)
|
||||
for _, value in pairs(table) do
|
||||
if value == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
---Remove a value from a table
|
||||
---@param table table
|
||||
---@param val any
|
||||
---@return nil
|
||||
function TableRemove(table, val)
|
||||
for i = #table, 1, -1 do
|
||||
if table[i] == val then
|
||||
table.remove(table, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- -- Get a random KEY from a table.
|
||||
-- function GetRandomKeyFromTable(t)
|
||||
-- local keyset = {}
|
||||
@ -341,16 +366,10 @@ end
|
||||
---@return nil
|
||||
function RemovePlayerStarterItems(player, surface_name)
|
||||
local playerSpawn = global.ocore.playerSpawns[player.name]
|
||||
local surface_override = surface_name
|
||||
if (playerSpawn == nil) then
|
||||
log("WARN - RemovePlayerStarterItems - No player spawn found for player: " .. player.name)
|
||||
else
|
||||
surface_override = playerSpawn.surface -- Use the player's spawn surface if we have it
|
||||
if (playerSpawn ~= nil) and (global.ocfg.surfaces_config[playerSpawn.surface]) ~= nil then
|
||||
local startItems = global.ocfg.surfaces_config[playerSpawn.surface].starting_items.player_start_items
|
||||
util.remove_safe(player, startItems)
|
||||
end
|
||||
|
||||
local startItems = global.ocfg.surfaces_config[surface_override].starting_items.player_start_items
|
||||
|
||||
util.remove_safe(player, startItems)
|
||||
end
|
||||
|
||||
--- Delete all chunks on a surface
|
||||
|
@ -66,14 +66,16 @@ end
|
||||
---@param event EventData.on_pre_surface_deleted
|
||||
---@return nil
|
||||
function RegrowthSurfaceDeleted(event)
|
||||
log("WARNING - RegrowthSurfaceDeleted: " .. game.surfaces[event.surface_index].name)
|
||||
local surface_name = game.surfaces[event.surface_index].name
|
||||
global.rg[surface_name] = nil
|
||||
for key,value in pairs(global.rg.active_surfaces) do
|
||||
if (value == surface_name) then
|
||||
table.remove(global.rg.active_surfaces, key)
|
||||
return
|
||||
break
|
||||
end
|
||||
end
|
||||
--TODO: Check if we need to reset any of the indexes in use.
|
||||
end
|
||||
|
||||
---Initialize the new surface for regrowth
|
||||
|
@ -194,7 +194,9 @@ function SeparateSpawnsInitPlayer(player_index)
|
||||
player.force = global.ocfg.gameplay.main_force_name
|
||||
end
|
||||
|
||||
player.permission_group = game.permissions.get_group("holding_pen")
|
||||
if (not player.admin) then
|
||||
player.permission_group = game.permissions.get_group("holding_pen")
|
||||
end
|
||||
|
||||
InitOarcGuiTabs(player)
|
||||
HideOarcGui(player)
|
||||
@ -420,13 +422,13 @@ end
|
||||
---@param chunkArea BoundingBox
|
||||
---@return nil
|
||||
function SetupAndClearSpawnAreas(surface, chunkArea)
|
||||
local spawn_config --[[@as OarcConfigSpawn]] = global.ocfg.surfaces_config[surface.name].spawn_config
|
||||
|
||||
for _,spawn in pairs(global.ocore.uniqueSpawns --[[@as OarcUniqueSpawnsTable]]) do
|
||||
if (spawn.surface ~= surface.name) then
|
||||
goto CONTINUE
|
||||
end
|
||||
|
||||
local spawn_config --[[@as OarcConfigSpawn]] = global.ocfg.surfaces_config[surface.name].spawn_config
|
||||
|
||||
-- Create a bunch of useful area and position variables
|
||||
local landArea = GetAreaAroundPos(spawn.position, spawn_config.general.spawn_radius_tiles + CHUNK_SIZE)
|
||||
-- local safeArea = GetAreaAroundPos(spawn.position, spawn_config.safe_area.safe_radius)
|
||||
@ -442,6 +444,7 @@ function SetupAndClearSpawnAreas(surface, chunkArea)
|
||||
-- }
|
||||
|
||||
-- Make chunks near a spawn safe by removing enemies
|
||||
-- TODO: Space Age will change this!
|
||||
if (util.distance(spawn.position, chunkAreaCenter) < spawn_config.safe_area.safe_radius) then
|
||||
RemoveAliensInArea(surface, chunkArea)
|
||||
|
||||
@ -458,11 +461,6 @@ function SetupAndClearSpawnAreas(surface, chunkArea)
|
||||
RemoveWormsInArea(surface, chunkArea, false, false, true, true) -- remove all huge/behemoth worms.
|
||||
end
|
||||
|
||||
-- TODO: Vanilla spawn point are not implemented yet.
|
||||
-- if (not spawn.vanilla) then
|
||||
|
||||
local enable_test = global.ocfg.gameplay.enable_moat_bridging
|
||||
|
||||
-- If the chunk is within the main land area, then clear trees/resources
|
||||
-- and create the land spawn areas (guaranteed land with a circle of trees)
|
||||
if CheckIfInArea(chunkAreaCenter, landArea) then
|
||||
@ -489,7 +487,6 @@ function SetupAndClearSpawnAreas(surface, chunkArea)
|
||||
end
|
||||
end
|
||||
|
||||
-- end -- Vanilla spawn point are not implemented yet.
|
||||
::CONTINUE:: -- Continue loop
|
||||
end
|
||||
end
|
||||
@ -501,14 +498,17 @@ function SeparateSpawnsGenerateChunk(event)
|
||||
local surface = event.surface
|
||||
local chunkArea = event.area
|
||||
|
||||
if (not global.ocore.surfaces[surface.name]) then return end
|
||||
-- Don't block based on spawn enabled.
|
||||
-- if (not global.ocore.surfaces[surface.name]) then return end
|
||||
|
||||
-- Helps scale worm sizes to not be unreasonable when far from the origin.
|
||||
-- TODO: Space Age will change this!
|
||||
if global.ocfg.gameplay.modified_enemy_spawning then
|
||||
DowngradeWormsDistanceBasedOnChunkGenerate(event)
|
||||
end
|
||||
|
||||
-- Downgrade resources near to spawns
|
||||
-- TODO: Space Age will change this!
|
||||
if global.ocfg.gameplay.scale_resources_around_spawns then
|
||||
DowngradeResourcesDistanceBasedOnChunkGenerate(surface, chunkArea)
|
||||
end
|
||||
|
@ -131,7 +131,7 @@ end
|
||||
---Show the surface select dropdown
|
||||
---@param parent_flow LuaGuiElement
|
||||
---@return nil
|
||||
function ShowSurfaceSelectDropdown(parent_flow)
|
||||
function CreateSurfaceSelectDropdown(parent_flow)
|
||||
local surfacesHorizontalFlow = parent_flow.add {
|
||||
name = "surfaces_horizontal_flow",
|
||||
type = "flow",
|
||||
@ -254,7 +254,7 @@ function CreateSpawnSettingsFrame(parent_flow, gameplay)
|
||||
|
||||
-- Pick surface
|
||||
if (gameplay.enable_spawning_on_other_surfaces) then
|
||||
ShowSurfaceSelectDropdown(spawn_settings_frame)
|
||||
CreateSurfaceSelectDropdown(spawn_settings_frame)
|
||||
end
|
||||
|
||||
-- Radio buttons to pick your team.
|
||||
@ -496,7 +496,7 @@ function CreateBuddySpawnFrame(parent_flow, player, enable_buddy_spawn)
|
||||
|
||||
if not enable_buddy_spawn then -- TODO: Confirm if this must also require enable_shared_spawns!!
|
||||
-- Add some note about this being disabled?
|
||||
AddLabel(buddy_spawn_frame, nil, { "oarc-buddy-spawn-disabled" }, my_label_style)
|
||||
AddLabel(buddy_spawn_frame, nil, { "oarc-buddy-spawn-disabled" }, my_warning_style)
|
||||
return
|
||||
end
|
||||
|
||||
@ -698,6 +698,8 @@ function SpawnOptsGuiClick(event)
|
||||
AcceptBuddyRequest(player, tags.requesting_buddy_name --[[@as string]])
|
||||
elseif (tags.setting == "reject_buddy_request") then
|
||||
RejectBuddyRequest(player, tags.requesting_buddy_name --[[@as string]])
|
||||
elseif (tags.setting == "surface_select") then
|
||||
event.element.items = GetAllowedSurfaces()
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -43,7 +43,7 @@ oarc-mod-server-msg=This is an additional message that will be displayed to play
|
||||
|
||||
oarc-mod-enable-main-team=Allow players to join the main team. This is the default team that is created when the game starts.
|
||||
oarc-mod-enable-separate-teams=Allow players to start their own teams (CO-OP only, No PVP).\n[color=red][font=default-bold]You must enable one or both of the main team and separate team options. Otherwise it will default to main team allowed only.[/font][/color]
|
||||
oarc-mod-enable-spawning-on-other-surfaces=Allow spawning on other surfaces.
|
||||
oarc-mod-enable-spawning-on-other-surfaces=Allow spawning on other surfaces. If enabled, by default all other surfaces will be available for players to spawn on. You can configure individual surfaces using the in game settings menu as well.
|
||||
|
||||
oarc-mod-allow-moats-around-spawns=Allow players to choose spawns with a moat around them.
|
||||
oarc-mod-enable-moat-bridging=If the spawn area is surrounded by land, the moat will have a small land bridge connecting it.
|
||||
@ -67,5 +67,5 @@ oarc-mod-minimum-online-time=The minimum time a player must be online before the
|
||||
oarc-mod-respawn-cooldown-min=The minimum time a player must wait before they can change their spawn point to a new location.
|
||||
|
||||
oarc-mod-enable-regrowth=Enables regrowth. This slowly removes inactive chunks over time. Any chunk with player structures will not be removed. This helps to keep the map (and file size) smaller over time.
|
||||
oarc-mod-enable-world-eater=Enables world eater. This is requires and is part of regrowth. This slowly checks all chunks for a lack of player structures and entities and marks them for removal. This helps to keep the map (and file size) smaller over time. This is more of an experimental feature, use at your own risk.
|
||||
oarc-mod-enable-world-eater=Enables world eater. This requires regrowth. This slowly checks all chunks for a lack of player structures and entities and marks them for removal. This helps to keep the map (and file size) smaller over time. This is more of an experimental feature, use at your own risk.
|
||||
oarc-mod-enable-abandoned-base-cleanup=Abandoned bases will be cleaned up if players leave within a short time of joining.
|
||||
|
@ -135,5 +135,7 @@ oarc-buddy-declined=__1__ declined your buddy request!
|
||||
oarc-spawn-wait=Please wait!
|
||||
oarc-wait-text=Your spawn is being created now.\nYou will be teleported there in __1__ seconds!\nPlease standby...
|
||||
|
||||
oarc-settings-tab-title=Settings
|
||||
oarc-settings-tab-admin-warning=You are an admin. You may change any of these settings. BE CAREFUL!
|
||||
oarc-settings-tab-title=Mod Settings
|
||||
oarc-settings-tab-admin-warning=You are an admin. You may change any of these settings. BE CAREFUL!
|
||||
|
||||
oarc-settings-tab-title-surface=Surface Settings
|
Loading…
Reference in New Issue
Block a user