diff --git a/fs_edit_options_dialog.lua b/fs_edit_options_dialog.lua index 4a9c7c5..d71c62e 100644 --- a/fs_edit_options_dialog.lua +++ b/fs_edit_options_dialog.lua @@ -8,13 +8,12 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields) -- Is the player working on this particular npc? local edit_mode = (yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id) - if(not(edit_mode) or not(fields.o_id)) then + if(not(edit_mode)) then return end local n_id = yl_speak_up.speak_to[pname].n_id local d_id = yl_speak_up.speak_to[pname].d_id - -- this is passed on as a hidden field - local o_id = fields.o_id + local o_id = yl_speak_up.speak_to[pname].o_id local dialog = yl_speak_up.speak_to[pname].dialog local n_dialog = dialog.n_dialogs[d_id] @@ -22,10 +21,12 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields) -- this meny is specific to an option for a dialog; if no dialog is selected, we really -- can't know what to do - if(not(d_id)) then + if(not(d_id) or not(o_id)) then return end + -- backwards compatibility to when this was a hidden field + fields.o_id = o_id -- handles changes to o_text_when_prerequisites_met, target dialog, adding of a new dialog local result = yl_speak_up.edit_mode_apply_changes(pname, fields) -- if a new option was added or the target dialog of this one changed, display the right new option @@ -81,22 +82,16 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields) -- the player clicked on a precondition elseif(fields.table_of_preconditions) then - -- remember which option was selected - yl_speak_up.speak_to[pname].o_id = o_id yl_speak_up.show_fs(player, "edit_preconditions", fields.table_of_preconditions) return -- the player clicked on an action elseif(fields.table_of_actions) then - -- remember which option was selected - yl_speak_up.speak_to[pname].o_id = o_id yl_speak_up.show_fs(player, "edit_actions", fields.table_of_actions) return -- the player clicked on an effect elseif(fields.table_of_effects) then - -- remember which option was selected - yl_speak_up.speak_to[pname].o_id = o_id yl_speak_up.show_fs(player, "edit_effects", fields.table_of_effects) return end @@ -125,6 +120,8 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id) " does not exist.]".. "button_exit[2,1.5;1,0.9;exit;Exit]" end + -- remember which option we are working at (better than a hidden field) + yl_speak_up.speak_to[pname].o_id = o_id -- are there any preconditions? local list_of_preconditions = "" local prereq = d_option.o_prerequisites @@ -379,8 +376,6 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id) "field[11.1,18.7;1.0,0.9;edit_option_o_sort;;".. minetest.formspec_escape(d_option.o_sort).."]".. "tooltip[edit_option_o_sort;o_sort: The lower the number, the higher up in the ".. - "list this option goes\nNegative values are ignored;#FFFFFF;#000000]".. - -- hidden field containing the value of o_id - "field[40,40;0.1,0.1;o_id;;"..minetest.formspec_escape(o_id).."]" + "list this option goes\nNegative values are ignored;#FFFFFF;#000000]" return formspec end