From 4a4ffefb85e6aa83f47e7298a69ce3be6af30f51 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 28 Jun 2021 00:38:12 +0200 Subject: [PATCH] fixed bug with saving when quitting --- fs_save_or_discard_or_back.lua | 4 ++-- show_fs.lua | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fs_save_or_discard_or_back.lua b/fs_save_or_discard_or_back.lua index 4d4619e..0de918b 100644 --- a/fs_save_or_discard_or_back.lua +++ b/fs_save_or_discard_or_back.lua @@ -113,9 +113,9 @@ yl_speak_up.get_fs_save_or_discard_changes = function(player, param) minetest.formspec_escape(d_id)..":]".. "hypertext[0.2,1;13.5,4;list_of_changes;".. minetest.formspec_escape(text) .. "\n".."]".. - "button[1.2,5.2;3,0.9;discard_dialog_changes;Discard changes]".. + "button_exit[1.2,5.2;3,0.9;discard_dialog_changes;Discard changes]".. "button[5.7,5.2;3,0.9;back_to_dialog_changes;Back]".. - "button[10.2,5.2;3,0.9;save_dialog_changes;Save changes]".. + "button_exit[10.2,5.2;3,0.9;save_dialog_changes;Save changes]".. "tooltip[save_dialog_changes;Save all changes to this dialog and "..target_name..".]".. "tooltip[discard_dialog_changes;Undo all changes and "..target_name..".]".. "tooltip[back_to_dialog_changes;Go back to dialog ".. diff --git a/show_fs.lua b/show_fs.lua index d6287a6..22fe852 100644 --- a/show_fs.lua +++ b/show_fs.lua @@ -82,6 +82,9 @@ yl_speak_up.show_fs = function(player, fs_name, param) return end local pname = player:get_player_name() + if(not(yl_speak_up.speak_to[pname])) then + return + end local last_fs = yl_speak_up.speak_to[pname].last_fs -- show the save or discard changes dialog @@ -98,6 +101,11 @@ yl_speak_up.show_fs = function(player, fs_name, param) yl_speak_up.speak_to[pname].next_fs_param = nil yl_speak_up.speak_to[pname].last_fs = fs_name yl_speak_up.speak_to[pname].last_fs_param = param + if(not(fs_name) or fs_name == "quit") then + yl_speak_up.speak_to[pname] = nil + yl_speak_up.edit_mode[pname] = nil + return + end -- the player clicked on "back" in the above dialog elseif(fs_name and fs_name == "show_last_fs") then @@ -156,9 +164,6 @@ yl_speak_up.show_fs = function(player, fs_name, param) yl_speak_up.speak_to[pname].last_fs = fs_name -- and its parameter yl_speak_up.speak_to[pname].last_fs_param = param - elseif(fs_name == "quit") then - -- player wanted to quit - return end -- this is here mostly to fascilitate debugging - so that really all calls to