From e306fe34665895081ce699f5c0fd60933f4b3f0e Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sun, 10 Mar 2024 16:10:46 +0100 Subject: [PATCH] d_name support for edit_options dialog --- editor/edit_mode_apply_changes.lua | 6 +++++- editor/fs/fs_edit_options_dialog.lua | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/editor/edit_mode_apply_changes.lua b/editor/edit_mode_apply_changes.lua index 0a2d1be..25efaa6 100644 --- a/editor/edit_mode_apply_changes.lua +++ b/editor/edit_mode_apply_changes.lua @@ -338,7 +338,11 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields) if(fields[ "d_id_"..k ]) then local new_target_dialog = yl_speak_up.prepare_new_dialog_for_option( dialog, pname, n_id, d_id, k, fields[ "d_id_"..k ], v.o_results) - if(new_target_dialog ~= fields[ "d_id_"..k ]) then + if(new_target_dialog ~= fields[ "d_id_"..k ] + and not( dialog.n_dialogs[new_target_dialog] + and dialog.n_dialogs[new_target_dialog].d_name + and dialog.n_dialogs[new_target_dialog].d_name == fields["d_id_"..k]) + ) then fields[ "d_id_"..k ] = new_target_dialog -- in options edit menu: show this update result["show_next_option"] = k diff --git a/editor/fs/fs_edit_options_dialog.lua b/editor/fs/fs_edit_options_dialog.lua index 5d253c6..16eaa38 100644 --- a/editor/fs/fs_edit_options_dialog.lua +++ b/editor/fs/fs_edit_options_dialog.lua @@ -475,7 +475,9 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id, calle -- the first entry will be "New dialog" local n = 1 for k, v in pairs(dialog.n_dialogs) do - dialog_list = dialog_list .. "," .. minetest.formspec_escape(v.d_id or "?") + local d_name = (v.d_name or v.d_id or "?") + -- build the list of available dialogs for the dropdown list(s) + dialog_list = dialog_list..","..minetest.formspec_escape(d_name) -- which one is the current dialog? n = n + 1 if(v.d_id == target_dialog) then @@ -710,7 +712,7 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id, calle else action_text = table.concat({action_text, -- allow to change the target dialog via a dropdown menu - "dropdown[10.2,0.0;3.0,0.7;d_id_", + "dropdown[11,0.0;9.8,0.7;d_id_", minetest.formspec_escape(o_id), ";", dialog_list, @@ -718,7 +720,7 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id, calle dialog_selected, ",]", "tooltip[10.2,0.0;3.0,0.7;Select the target dialog with which the NPC shall react ".. - "to this answer. Currently, dialog \"", + "to this answer.\nCurrently, dialog \"", minetest.formspec_escape(target_dialog), "\" is beeing displayed.;#FFFFFF;#000000]", -- ..and what the NPC will reply to that answer