diff --git a/fs_add_quest_steps.lua b/fs_add_quest_steps.lua index 7770083..43aeb4f 100644 --- a/fs_add_quest_steps.lua +++ b/fs_add_quest_steps.lua @@ -533,6 +533,58 @@ yl_speak_up.quest_get_location_candidate_list = function(pname, quest_location_l end +-- describe a location where a quest step can be set; also used by yl_speak_up.fs_manage_quest_steps +yl_speak_up.quest_step_show_where_set = function(pname, formspec, label, n_id, d_id, o_id) + if(not(pname)) then + return + end + -- what are we talking about? + local dialog = nil + if(yl_speak_up.speak_to[pname] and yl_speak_up.speak_to[pname].n_id == n_id) then + dialog = yl_speak_up.speak_to[pname].dialog + else + dialog = yl_speak_up.load_dialog(n_id, false) + end + local name_txt = "- ? -" + local dialog_txt = "- ? -" + local option_txt = "- ? -" + if(yl_speak_up.check_if_dialog_has_option(dialog, d_id, o_id)) then + dialog_txt = dialog.n_dialogs[d_id].d_text or "- ? -" + option_txt = dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_met or "- ? -" + name_txt = (dialog.n_npc or "- ? -") + if(dialog.n_description and dialog.n_description ~= "") then + name_txt = name_txt..", "..tostring(dialog.n_description) + end + end + -- are we dealing with an NPC? + local id_label = "the block at position " + if(n_id and string.sub(n_id, 1, 2) == "n_") then + id_label = "NPC " + end + + table.insert(formspec, "label[0.2,0;") + table.insert(formspec, label or "which will be set by ") + table.insert(formspec, id_label) + table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(n_id))) + table.insert(formspec, ":]") + table.insert(formspec, "label[1.0,0.4;") + table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(name_txt))) + table.insert(formspec, "]") + table.insert(formspec, "label[0.2,0.9;when answering to dialog ") + table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(d_id))) + table.insert(formspec, ":]") + table.insert(formspec, "textarea[1.0,1.1;16,1.8;;;") + table.insert(formspec, minetest.formspec_escape(dialog_txt)) + table.insert(formspec, "]") + table.insert(formspec, "label[0.2,3.2;with the following answer/option ") + table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(o_id))) + table.insert(formspec, ":]") + table.insert(formspec, "label[1.0,3.6;") + table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(option_txt))) + table.insert(formspec, "]") +end + + -- param is unused yl_speak_up.get_fs_add_quest_steps = function(player, param) local res = yl_speak_up.player_is_working_on_quest(player) @@ -653,47 +705,14 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param) y_pos = 8.3 -- add a quest step to an NPC or location elseif(mode == "assign_quest_step") then + table.insert(formspec, "container[0,3.3;17,4]") -- what are we talking about? local n_id = yl_speak_up.speak_to[pname].n_id local d_id = yl_speak_up.speak_to[pname].d_id local o_id = yl_speak_up.speak_to[pname].o_id - local dialog = yl_speak_up.speak_to[pname].dialog - local name_txt = "- ? -" - local dialog_txt = "- ? -" - local option_txt = "- ? -" - if(yl_speak_up.check_if_dialog_has_option(dialog, d_id, o_id)) then - dialog_txt = dialog.n_dialogs[d_id].d_text or "- ? -" - option_txt = dialog.n_dialogs[d_id].d_options[o_id].o_text_when_prerequisites_met or "- ? -" - name_txt = (dialog.n_npc or "- ? -") - if(dialog.n_description and dialog.n_description ~= "") then - name_txt = name_txt..", "..tostring(dialog.n_description) - end - end - -- are we dealing with an NPC? - local id_label = "the block at position " - if(n_id and string.sub(n_id, 1, 2) == "n_") then - id_label = "NPC " - end - - table.insert(formspec, "label[0.2,3.3;which will be set by ") - table.insert(formspec, id_label) - table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(n_id))) - table.insert(formspec, ":]") - table.insert(formspec, "label[1.0,3.7;") - table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(name_txt))) - table.insert(formspec, "]") - table.insert(formspec, "label[0.2,4.2;when answering to dialog ") - table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(d_id))) - table.insert(formspec, ":]") - table.insert(formspec, "textarea[1.0,4.4;16,1.8;;;") - table.insert(formspec, minetest.formspec_escape(dialog_txt)) - table.insert(formspec, "]") - table.insert(formspec, "label[0.2,6.5;with the following answer/option ") - table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(o_id))) - table.insert(formspec, ":]") - table.insert(formspec, "label[1.0,6.9;") - table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(option_txt))) - table.insert(formspec, "]") + -- describe where in the dialog of the NPC or location this quest step shall be set + yl_speak_up.quest_step_show_where_set(pname, formspec, "which will be set by ", n_id, d_id, o_id) + table.insert(formspec, "container_end[]") y_pos = 7.8 -- which NPC may contribute to the quest?