catch some error conditions

This commit is contained in:
Sokomine 2021-06-02 00:56:46 +02:00
parent 786ca77c7f
commit a8c9321672

View File

@ -830,6 +830,16 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id)
local n_dialog = dialog.n_dialogs[d_id]
local d_option = n_dialog.d_options[o_id]
-- currently no trade running (we're editing options)
yl_speak_up.trade[pname] = nil
yl_speak_up.speak_to[pname].trade_id = nil
if(not(d_option)) then
return "size[6,2]"..
"label[0.2,0.5;Ups! Option "..minetest.formspec_escape(tostring(o_id))..
" does not exist.]"..
"button_exit[2,1.5;1,0.9;exit;Exit]"
end
-- are there any preconditions?
local list_of_preconditions = ""
local prereq = d_option.o_prerequisites
@ -1088,6 +1098,10 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id)
return get_error_message()
end
-- currently no trade running (we're editing options)
yl_speak_up.trade[pname] = nil
yl_speak_up.speak_to[pname].trade_id = nil
--[[ If we have an explicit call for a certain d_id, we grab it from parameters.
If not, we grab in from context.
When neither are present, we grab it from d_sort
@ -1826,6 +1840,7 @@ yl_speak_up.show_fs = function(player, fs_name, param)
-- "confirm_save" does not have its own option here; doesn't have a get_fs_-function either
elseif(fs_name == "edit_option_dialog") then
-- the optional "caller" parameter can be used for debugging
if(not(param)) then
param = {}
end
@ -2751,7 +2766,8 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
-- if a new option was added or the target dialog of this one changed, display the right new option
if(result and result["show_next_option"] and n_dialog.d_options[result["show_next_option"]]) then
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = n_id, d_id = d_id, o_id = result["show_next_option"]})
{n_id = n_id, d_id = d_id, o_id = result["show_next_option"],
caller="show_next_option"})
return
end
@ -2784,7 +2800,7 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
end
-- show that dialog; fallback: show the same (o_id) again
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = n_id, d_id = d_id, o_id = o_found})
{n_id = n_id, d_id = d_id, o_id = o_found, caller="prev option"})
return
-- the player wants to see the next option/answer
@ -2799,7 +2815,7 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
end
-- show that dialog; fallback: show the same (o_id) again
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = n_id, d_id = d_id, o_id = o_found})
{n_id = n_id, d_id = d_id, o_id = o_found, caller="next option"})
return
-- show the trade associated with this dialog and option
@ -3080,7 +3096,7 @@ yl_speak_up.input_talk = function(player, formname, fields)
or fields["effects_"..o_id]) then
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = yl_speak_up.speak_to[pname].n_id,
d_id = d_id, o_id = o_found})
d_id = d_id, o_id = o_id, caller="button"})
return
end
end