From cbb93db37a72094a8d7b3b5f8887d65951213d10 Mon Sep 17 00:00:00 2001 From: Oarcinae Date: Wed, 6 Nov 2024 10:45:58 -0500 Subject: [PATCH] Fix #246 gui crash on player self reset button click --- changelog.txt | 5 +++++ info.json | 2 +- lib/gui_tabs/spawn_controls.lua | 5 +++++ lib/separate_spawns_guis.lua | 7 +++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/changelog.txt b/changelog.txt index 3040b3e..db637df 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 2.1.9 +Date: 2024-11-06 + Bugfixes: + - Fix crash when clicking player self reset button again before confirmation dialog is closed. +--------------------------------------------------------------------------------------------------- Version: 2.1.8 Date: 2024-11-05 Changes: diff --git a/info.json b/info.json index b750beb..5475ce9 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "oarc-mod", - "version": "2.1.8", + "version": "2.1.9", "factorio_version": "2.0", "title": "Oarc Multiplayer Spawn", "author": "Oarcinae", diff --git a/lib/gui_tabs/spawn_controls.lua b/lib/gui_tabs/spawn_controls.lua index 0b0b529..7c30a04 100644 --- a/lib/gui_tabs/spawn_controls.lua +++ b/lib/gui_tabs/spawn_controls.lua @@ -311,6 +311,11 @@ end ---@param player LuaPlayer ---@return nil function DisplayPlayerResetConfirmationGUI(player) + + if (player.gui.screen.self_reset_confirm ~= nil) then + player.gui.screen.self_reset_confirm.destroy() + end + local self_reset_gui = player.gui.screen.add { name = "self_reset_confirm", type = "frame", diff --git a/lib/separate_spawns_guis.lua b/lib/separate_spawns_guis.lua index 434a161..1727f91 100644 --- a/lib/separate_spawns_guis.lua +++ b/lib/separate_spawns_guis.lua @@ -16,12 +16,15 @@ function DisplayWelcomeTextGui(player) end --Delete existing guis - if (player.gui.screen["welcome_msg"] ~= nil) then + if (player.gui.screen.welcome_msg ~= nil) then player.gui.screen.welcome_msg.destroy() end - if (player.gui.screen["spawn_opts"] ~= nil) then + if (player.gui.screen.spawn_opts ~= nil) then player.gui.screen.spawn_opts.destroy() end + if (player.gui.screen.self_reset_confirm ~= nil) then + player.gui.screen.self_reset_confirm.destroy() + end local welcome_gui = player.gui.screen.add { name = "welcome_msg",