added added save button to main dialog

This commit is contained in:
Sokomine 2021-06-28 01:27:50 +02:00
parent 4a4ffefb85
commit 703770794e
2 changed files with 11 additions and 0 deletions

View File

@ -915,6 +915,8 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id)
-- allow to edit name and description of the NPC
table.insert(formspec, "button[13.4,0.3;2,0.9;button_edit_name_and_description;Edit]")
table.insert(formspec, "tooltip[button_edit_name_and_description;Edit name and description of your NPC.]")
table.insert(formspec, "button[15.7,0.3;2,0.9;button_save_dialog;Save]")
table.insert(formspec, "tooltip[button_save_dialog;Save this dialog.]")
table.insert(formspec, "textarea[0.2,5;19.6,17.8;d_text;;")
table.insert(formspec, minetest.formspec_escape(active_dialog.d_text))
@ -2218,6 +2220,12 @@ yl_speak_up.input_talk = function(player, formname, fields)
return
end
if(edit_mode and fields.button_save_dialog) then
yl_speak_up.show_fs(player, "talk",
{n_id = n_id, d_id = yl_speak_up.speak_to[pname].d_id, do_save = true})
return
end
-- start edit mode (requires npc_talk_owner)
if fields.button_start_edit_mode then
-- check if this particular NPC is really owned by this player or if the player has global privs

View File

@ -136,6 +136,9 @@ yl_speak_up.show_fs = function(player, fs_name, param)
and param and param.d_id and param.d_id ~= d_id) then
-- diffrent parameters: save (if needed)
show_save_fs = true
elseif(fs_name == "talk" and param and param.do_save) then
-- player clicked on save button
show_save_fs = true
-- leaving a dialog: save!
elseif(last_fs == "talk" and fs_name ~= last_fs) then
show_save_fs = true