diff --git a/fs_edit_general.lua b/fs_edit_general.lua index 9beb93c..d2bb74c 100644 --- a/fs_edit_general.lua +++ b/fs_edit_general.lua @@ -212,6 +212,7 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields, -- field inputs: those do not trigger a sending of the formspec on their own + local was_changed = false -- are we talking about an inventory? -- (inventory only applies to preconditions; not effects) local data = yl_speak_up.speak_to[pname][ tmp_data_cache ] @@ -245,23 +246,27 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields, elseif(fields.var_cmp_value and data and data.what and data.what == 2 and id_prefix ~= "a_") then data.var_cmp_value = fields.var_cmp_value + was_changed = true -- text for a chat message elseif(fields.chat_msg_text and data and data.what and data.what == 6 and id_prefix == "r_") then data.chat_msg_text = fields.chat_msg_text + was_changed = true elseif(fields.custom_param and fields.custom_param ~= "- Insert a text that is passed on to your function here -" and fields.custom_param ~= "" and data and data.what and data.what == 7 and id_prefix == "a_") then data.custom_param = fields.custom_param + was_changed = true elseif(fields.action_item_quest_id and fields.action_item_quest_id ~= "" and fields.action_item_quest_id ~= "- none set -" and data and data.what and data.what == 4 and id_prefix == "a_") then data.item_quest_id = fields.action_item_quest_id + was_changed = true end -- action_item_quest_id and action_item_desc can be set at the same time if(fields.action_item_desc @@ -270,11 +275,13 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields, and data and data.what and data.what == 4 and id_prefix == "a_") then -- TODO: check if it diffrent from the default one of the stack data.item_desc = fields.action_item_desc + was_changed = true end if(fields.quest_question and fields.quest_question ~= "" and data and data.what and data.what == 6 and id_prefix == "a_") then data.quest_question = fields.quest_question + was_changed = true end -- quest question and answer can be given with the same press of the save button if(fields.quest_answer @@ -282,6 +289,7 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields, and fields.quest_answer ~= "" and data and data.what and data.what == 6 and id_prefix == "a_") then data.quest_answer = fields.quest_answer + was_changed = true end -- the save button was pressed @@ -656,27 +664,28 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields, -- selections in a dropdown menu (they trigger sending the formspec) -- select a general direction/type first - if(fields.select_what) then + -- but *not* when enter was pressed (enter sends them all) + if(fields.select_what and not(fields.key_enter)) then local nr = table.indexof(check_what, fields.select_what) yl_speak_up.speak_to[pname][ tmp_data_cache ] = { what = nr } - + end -- select a subtype for the "a trade" selection - elseif(fields.select_trade) then + if(fields.select_trade) then local nr = table.indexof(check_trade, fields.select_trade) yl_speak_up.speak_to[pname][ tmp_data_cache ].trade = nr - + end -- select a subtype for the inventory selection (player or NPC) - elseif(fields.select_inv) then + if(fields.select_inv) then local nr = table.indexof(check_inv, fields.select_inv) yl_speak_up.speak_to[pname][ tmp_data_cache ].inv = nr - + end -- select data regarding a block - elseif(fields.select_block) then + if(fields.select_block) then local nr = table.indexof(check_block, fields.select_block) yl_speak_up.speak_to[pname][ tmp_data_cache ].block = nr - + end -- select data regarding a variable - elseif(fields.select_variable) then + if(fields.select_variable) then -- get the list of available variables (with the same elements -- and the same sort order as when the dropdown was displayed) local var_list = get_sorted_player_var_list_function(pname) @@ -685,17 +694,17 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields, yl_speak_up.speak_to[pname][ tmp_data_cache ].variable = nr yl_speak_up.speak_to[pname][ tmp_data_cache ].variable_name = var_list[ nr ] end - + end -- select data regarding an operator - elseif(fields.select_operator) then + if(fields.select_operator) then local nr = table.indexof(check_operator, fields.select_operator) yl_speak_up.speak_to[pname][ tmp_data_cache ].operator = nr - - elseif(fields.select_on_failure) then + end + if(fields.select_on_failure) then -- in this case we really want the name of the target dialog yl_speak_up.speak_to[pname][ tmp_data_cache ].on_failure = fields.select_on_failure - - elseif(fields.select_on_action_failure + end + if(fields.select_on_action_failure and data and data.what and id_prefix == "a_") then local dialog = yl_speak_up.speak_to[pname].dialog local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs) @@ -718,7 +727,12 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields, or fields.select_variable or fields.select_operator or fields.select_on_failure or fields.select_on_action_failure - or fields.back_from_error_msg)) then + or fields.back_from_error_msg + or was_changed + or fields.key_enter + or fields.quit + -- return was pressed + or fields.key_enter_field)) then yl_speak_up.show_fs(player, formspec_input_to) return end