moved rest of minetest.show_formspec to yl_speak_up.show_fs

This commit is contained in:
Sokomine 2021-05-31 22:34:01 +02:00
parent 85bdf88ba9
commit 786ca77c7f
2 changed files with 29 additions and 14 deletions

View File

@ -1793,13 +1793,21 @@ end)
-- call show_formspec with the right input_* function for the right formspec
-- (handles all show_formspec-calls)
yl_speak_up.show_fs = function(player, fs_name, param)
if(not(player)) then
return
end
local pname = player:get_player_name()
if(fs_name == "TODO") then
-- this is here mostly to fascilitate debugging - so that really all calls to
-- minetest.show_formspec are routed through here
if(fs_name == "msg") then
if(not(param)) then
param = {}
end
minetest.show_formspec(pname, param.input_to, param.formspec)
elseif(fs_name == "optiondialog") then
if(not(param)) then
@ -2078,7 +2086,8 @@ yl_speak_up.input_setdialog = function(player, formname, fields)
-- Button Options with invalid d_id: Show options formspec
if fields.button_option and fields.d_id and fields.d_id == yl_speak_up.text_new_dialog_id then
yl_speak_up.speak_to[pname].d_id = yl_speak_up.text_new_dialog_id
minetest.show_formspec(pname, "yl_speak_up:optiondialog", get_error_message())
yl_speak_up.show_fs(player, "msg", {input_to = "yl_speak_up:optiondialog",
formspec = get_error_message()})
return
end
@ -2294,7 +2303,8 @@ yl_speak_up.save_changes_and_switch_to_other_dialog = function(player, fields, t
-- hidden field telling about the target dialog
"field[20,20;0.1,0.1;goto_target_dialog;target_dialog;"..minetest.formspec_escape(target_dialog).."]"
-- actaully show the formspec to the player
minetest.show_formspec(pname, "yl_speak_up:confirm_save", formspec)
yl_speak_up.show_fs(player, "msg", {input_to = "yl_speak_up:confirm_save",
formspec = formspec})
return
end
-- if there is nothing that needs to be saved or discarded: allow quit/exit
@ -2948,7 +2958,8 @@ yl_speak_up.input_talk = function(player, formname, fields)
-- the player wants to change name and description; show the formspec
if(edit_mode and fields.button_edit_name_and_description) then
-- this is not the initial config - but the same formspec can be used
minetest.show_formspec(pname, "yl_speak_up:talk", get_fs_initial_config(player, n_id, yl_speak_up.speak_to[pname].d_id, false))
yl_speak_up.show_fs(player, "msg", {input_to = "yl_speak_up:talk", formspec =
get_fs_initial_config(player, n_id, yl_speak_up.speak_to[pname].d_id, false)})
return
end
@ -3415,13 +3426,13 @@ function yl_speak_up.talk(self, clicker)
-- show a formspec to other players that this NPC is busy
if(not(yl_speak_up.may_edit_npc(clicker, n_id))) then
-- show a formspec so that the player knows that he may come back later
minetest.show_formspec(pname, "yl_spaek_up:ignore",
yl_speak_up.show_fs(player, "msg", {input_to = "yl_spaek_up:ignore", formspec =
"size[6,2]"..
"label[1.2,0.0;"..minetest.formspec_escape((self.yl_speak_up.npc_name or "This NPC")..
" [muted]").."]"..
"label[0.2,0.5;Sorry! I'm currently busy learning new things.]"..
"label[0.2,1.0;Please come back later.]"..
"button_exit[2.5,1.5;1,0.9;ok;Ok]")
"button_exit[2.5,1.5;1,0.9;ok;Ok]"})
return
end
-- allow the owner to edit (and subsequently unmute) the npc

View File

@ -332,10 +332,12 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields)
end
-- show error message (that leads back to this formspec)
if(error_msg) then
minetest.show_formspec(pname, "yl_speak_up:add_trade_simple",
"size[6,2]"..
"label[0.2,0.5;"..error_msg.."]"..
"button[2,1.5;1,0.9;back_from_error_msg;Back]")
yl_speak_up.show_fs(player, "msg", {
input_to = "yl_speak_up:add_trade_simple",
formspec =
"size[6,2]"..
"label[0.2,0.5;"..error_msg.."]"..
"button[2,1.5;1,0.9;back_from_error_msg;Back]"})
return
end
@ -367,10 +369,12 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields)
if(dialog.trades[ trade_id ] and dialog.trades[ trade_id ].d_id) then
yl_speak_up.speak_to[pname].trade_id = trade_id
-- tell the player that the new trade has been added
minetest.show_formspec(pname, "yl_speak_up:do_trade_simple",
"size[6,2]"..
"label[0.2,0.5;The new trade has been configured successfully.]"..
"button[1.5,1.5;2,0.9;trade_simple_stored;Show trade]")
yl_speak_up.show_fs(player, "msg", {
input_to = "yl_speak_up:do_trade_simple",
formspec =
"size[6,2]"..
"label[0.2,0.5;The new trade has been configured successfully.]"..
"button[1.5,1.5;2,0.9;trade_simple_stored;Show trade]"})
-- return back to trade list
elseif(not(o_id)) then
-- we are no longer trading