show target dialog for on_failure effect

This commit is contained in:
Sokomine 2021-06-20 00:58:08 +02:00
parent c93012338d
commit 73aaa15c44

View File

@ -653,7 +653,6 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
end
end
-- selections in a dropdown menu (they trigger sending the formspec)
-- select a general direction/type first
@ -906,6 +905,8 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
data.action_failure_dialog = math.max(1,
table.indexof(sorted_dialog_list, e[ "a_on_failure" ]))
end
-- write that data back
yl_speak_up.speak_to[pname][ tmp_data_cache ] = data
end
local save_button = "button[5.0,9.8;1,0.7;save_element;Save]"
@ -1104,12 +1105,21 @@ yl_speak_up.get_fs_edit_option_related = function(player, table_click_result,
else
nr = table.indexof(sorted_dialog_list, data.on_failure)
end
local on_failure_dialog = ""
if(dialog and dialog.n_dialogs and dialog.n_dialogs[ data.on_failure ]) then
on_failure_dialog =
"label[0.2,5.5;This will switch to dialog "..tostring(data.on_failure)..":]"..
"hypertext[1.2,6.0;19.6,2.5;d_text;<normal>"..
minetest.formspec_escape(dialog.n_dialogs[ data.on_failure ].d_text or "?")..
"\n</normal>".."]"
end
formspec = formspec..
"label[0.2,3.3;If the *previous* effect failed,]"..
"label[0.2,3.8;switch to the following dialog:]"..
"dropdown[5.0,3.5;6.5,0.6;select_on_failure;"..
table.concat(sorted_dialog_list, ",")..";"..
tostring(nr)..";]"
tostring(nr)..";]"..
on_failure_dialog
-- "send a chat message to all players" -- 6
elseif(data.what and id_prefix == "r_" and data.what == 6) then