moved edit_options_dialog to yl_speak_up.show_fs

This commit is contained in:
Sokomine 2021-05-31 21:52:04 +02:00
parent cf145bb07d
commit 60d17124b6
2 changed files with 25 additions and 15 deletions

View File

@ -1800,7 +1800,17 @@ yl_speak_up.show_fs = function(player, fs_name, param)
local pname = player:get_player_name()
if(fs_name == "TODO") then
elseif(fs_name == "edit_option_dialog") then
if(not(param)) then
param = {}
end
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
yl_speak_up.get_fs_edit_option_dialog(player, param.n_id, param.d_id, param.o_id))
elseif(fs_name == "talk") then
if(not(param)) then
param = {}
end
minetest.show_formspec(pname, "yl_speak_up:talk",
yl_speak_up.get_fs_talkdialog(player, param.n_id, param.d_id))
@ -2728,8 +2738,8 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
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
if(result and result["show_next_option"] and n_dialog.d_options[result["show_next_option"]]) then
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, result["show_next_option"]))
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = n_id, d_id = d_id, o_id = result["show_next_option"]})
return
end
@ -2761,8 +2771,8 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
end
end
-- show that dialog; fallback: show the same (o_id) again
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, o_found))
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = n_id, d_id = d_id, o_id = o_found})
return
-- the player wants to see the next option/answer
@ -2776,8 +2786,8 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
end
end
-- show that dialog; fallback: show the same (o_id) again
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, o_found))
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = n_id, d_id = d_id, o_id = o_found})
return
-- show the trade associated with this dialog and option
@ -3055,9 +3065,9 @@ yl_speak_up.input_talk = function(player, formname, fields)
if( fields["edit_option_"..o_id]
or fields["conditions_"..o_id]
or fields["effects_"..o_id]) then
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
yl_speak_up.get_fs_edit_option_dialog(
player, yl_speak_up.speak_to[pname].n_id, d_id, o_id))
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})
return
end
end

View File

@ -46,8 +46,8 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields)
yl_speak_up.speak_to[pname].target_d_id = nil
yl_speak_up.speak_to[pname].trade_id = nil
-- go to the edit options dialog
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
yl_speak_up.get_fs_edit_option_dialog(player, n_id, tr.d_id, tr.o_id))
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = n_id, d_id = tr.d_id, o_id = tr.o_id})
return
end
end
@ -121,8 +121,8 @@ yl_speak_up.input_do_trade_simple = function(player, formname, fields)
-- if in edit mode: go back to the edit options dialog
if(yl_speak_up.edit_mode[pname] == n_id and n_id and o_id) then
-- go to the edit options dialog
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, o_id))
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = n_id, d_id = d_id, o_id = o_id})
return
-- show either the current or the target dialog
elseif(target_dialog) then
@ -381,8 +381,8 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields)
-- we are no longer trading
yl_speak_up.speak_to[pname].trade_id = nil
-- ..else go back to the edit options formspec
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
yl_speak_up.get_fs_edit_option_dialog(player, n_id, d_id, o_id))
yl_speak_up.show_fs(player, "edit_option_dialog",
{n_id = n_id, d_id = d_id, o_id = o_id})
end
end