diff --git a/api/api_decorated.lua b/api/api_decorated.lua
index b7f6e8c..d2f08e6 100644
--- a/api/api_decorated.lua
+++ b/api/api_decorated.lua
@@ -178,7 +178,38 @@ yl_speak_up.get_pname_for_old_fs = function(pname)
end
-yl_speak_up.show_fs_decorated = function(pname, edit_mode, h,
+
+-- display the window with the text the NPC is saying
+-- Note: In edit mode, and if there is a dialog selected, the necessary
+-- elements for editing said text are done in the calling function.
+yl_speak_up.show_fs_npc_text = function(pname, formspec, dialog, alternate_text, active_dialog, fs_version)
+ if(alternate_text and active_dialog and active_dialog.d_text) then
+ alternate_text = string.gsub(alternate_text, "%$TEXT%$", active_dialog.d_text)
+ elseif(active_dialog and active_dialog.d_text) then
+ alternate_text = active_dialog.d_text
+ end
+ -- replace $NPC_NAME$ etc.
+ local t = minetest.formspec_escape(yl_speak_up.replace_vars_in_text(
+ alternate_text, dialog, pname))
+ if(fs_version > 2) then
+ yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
+ "hypertext", "0.2,5;19.6,17.8", "d_text",
+ ""..t.."\n",
+ t:trim()..";#000000;#FFFFFF",
+ true)
+ else
+ yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
+ "textarea", "0.2,5;19.6,17.8", "",
+ ";"..t.."\n",
+ t:trim(),
+ true)
+ end
+ return formspec
+end
+
+
+
+yl_speak_up.show_fs_decorated = function(pname, npc_text_already_printed, h,
alternate_text,
add_this_to_left_window,
add_this_to_bottom_window,
@@ -279,28 +310,8 @@ yl_speak_up.show_fs_decorated = function(pname, edit_mode, h,
-- display the window with the text the NPC is saying
-- Note: In edit mode, and if there is a dialog selected, the necessary
-- elements for editing said text are done in the calling function.
- if(not(edit_mode) or not(dialog) or not(dialog.n_dialogs)) then
- if(alternate_text and active_dialog and active_dialog.d_text) then
- alternate_text = string.gsub(alternate_text, "%$TEXT%$", active_dialog.d_text)
- elseif(active_dialog and active_dialog.d_text) then
- alternate_text = active_dialog.d_text
- end
- -- replace $NPC_NAME$ etc.
- local t = minetest.formspec_escape(yl_speak_up.replace_vars_in_text(
- alternate_text, dialog, pname))
- if(fs_version > 2) then
- yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
- "hypertext", "0.2,5;19.6,17.8", "d_text",
- ""..t.."\n",
- t:trim()..";#000000;#FFFFFF",
- true)
- else
- yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
- "textarea", "0.2,5;19.6,17.8", "",
- ";"..t.."\n",
- t:trim(),
- true)
- end
+ if(not(npc_text_already_printed) or not(dialog) or not(dialog.n_dialogs)) then
+ yl_speak_up.show_fs_npc_text(pname, formspec, dialog, alternate_text, active_dialog, fs_version)
end
-- add custom things (mostly for editing a dialog) to the window shown left
diff --git a/edit_mode.lua b/edit_mode.lua
index 5979d43..c7250c4 100644
--- a/edit_mode.lua
+++ b/edit_mode.lua
@@ -44,9 +44,9 @@ end
-- shows the text the NPC "speaks" and adds edit and navigation buttons
-- (all only in *edit_mode*)
local old_talkdialog_main_text = yl_speak_up.get_fs_talkdialog_main_text
-yl_speak_up.get_fs_talkdialog_main_text = function(pname, formspec, h, dialog, dialog_list, c_d_id, active_dialog)
+yl_speak_up.get_fs_talkdialog_main_text = function(pname, formspec, h, dialog, dialog_list, c_d_id, active_dialog, alternate_text)
if(not(yl_speak_up.in_edit_mode(pname))) then
- return old_talkdialog_main_text(pname, formspec, h, dialog, dialog_list, c_d_id, active_dialog)
+ return old_talkdialog_main_text(pname, formspec, h, dialog, dialog_list, c_d_id, active_dialog, alternate_text)
end
local d_id_to_dropdown_index = {}
-- allow to change skin, wielded items etc.
diff --git a/fs/fs_talkdialog.lua b/fs/fs_talkdialog.lua
index c6e24b5..dc8c221 100644
--- a/fs/fs_talkdialog.lua
+++ b/fs/fs_talkdialog.lua
@@ -322,7 +322,9 @@ end
-- helper function for yl_speak_up.get_fs_talkdialog:
-- shows the text the NPC "speaks"
-- (this is pretty boring; the more intresting stuff happens in edit_mode)
-yl_speak_up.get_fs_talkdialog_main_text = function(pname, formspec, h, dialog, dialog_list, c_d_id, active_dialog)
+yl_speak_up.get_fs_talkdialog_main_text = function(pname, formspec, h, dialog, dialog_list, c_d_id, active_dialog, alternate_text)
+ local fs_version = yl_speak_up.fs_version[pname]
+ formspec = yl_speak_up.show_fs_npc_text(pname, formspec, dialog, alternate_text, active_dialog, fs_version)
return {h = h, formspec = formspec, d_id_to_dropdown_index = {}, dialog_list = dialog_list}
end
@@ -594,9 +596,6 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
"label[0.2,0.5;Ups! Something went wrong. Please try again.]"
end
- -- Is the player working on this particular npc?
- local edit_mode = (yl_speak_up.edit_mode[pname] == yl_speak_up.speak_to[pname].n_id)
-
-- evaluate the preconditions of each option and check if the option can be offered
local allowed = yl_speak_up.calculate_displayable_options(pname, active_dialog.d_options,
-- avoid loops by limiting max recoursion depths for autoanswers
@@ -625,7 +624,8 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
-- allow to change skin, wielded items etc.
-- display the window with the text the NPC is saying (diffrent in *edit_mode*)
local res_edit_top = yl_speak_up.get_fs_talkdialog_main_text(
- pname, formspec, h, dialog, dialog_list, c_d_id, active_dialog)
+ pname, formspec, h, dialog, dialog_list, c_d_id, active_dialog,
+ alternate_text)
-- we are finished with adding buttons and text etc. to the left side of the formspec
local left_window_fs = table.concat(res_edit_top.formspec, "\n")
dialog_list = res_edit_top.dialog_list
@@ -718,7 +718,7 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec
-- we are finished with adding buttons to the bottom of the formspec
local bottom_window_fs = table.concat(formspec, "\n")
- return yl_speak_up.show_fs_decorated(pname, edit_mode, h, alternate_text,
+ return yl_speak_up.show_fs_decorated(pname, true, h, alternate_text,
left_window_fs, bottom_window_fs,
active_dialog, h)
end