diff --git a/fs_talkdialog.lua b/fs_talkdialog.lua index 447d5c3..999a86e 100644 --- a/fs_talkdialog.lua +++ b/fs_talkdialog.lua @@ -447,9 +447,12 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec owner_info = "\n\n(owned by "..minetest.formspec_escape(yl_speak_up.npc_owner[ n_id ])..")" end + local fs_version = "1" if formspec_v >= 4 then + fs_version = "3" + end formspec = { - "formspec_version[3]", + "formspec_version["..fs_version.."]", "size[57,33]", "position[0,0.45]", "anchor[0,0.45]", @@ -482,14 +485,7 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec "image[53.75,24.75;1,6;yl_speak_up_bg_dialog_hr.png]", "image[0.75,23.75;53,1;yl_speak_up_bg_dialog_vt.png]", "image[0.75,30.75;53,1;yl_speak_up_bg_dialog_vb.png]", - "style_type[button;bgcolor=#a37e45]", - "style_type[button_exit;bgcolor=#a37e45]", -- Dialog - --[[ - "background[-1,-1;22,25;yl_speak_up_bg_dialog2.png;false]", - "background[-1,23;58,10;yl_speak_up_bg_dialog2.png;false]", - "style_type[button;bgcolor=#a37e45]", - ]]-- "label[0.3,0.6;", minetest.formspec_escape(dialog.n_npc), "]", @@ -500,6 +496,13 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec portrait, "]", } + if formspec_v >= 4 then + -- add those things that only exist in formspec_v >= 4 + table.insert(formspec, "style_type[button;bgcolor=#a37e45]") + table.insert(formspec, "style_type[button_exit;bgcolor=#a37e45]") -- Dialog + -- table.insert(formspec, "background[-1,-1;22,25;yl_speak_up_bg_dialog2.png;false]") + -- table.insert(formspec, "background[-1,23;58,10;yl_speak_up_bg_dialog2.png;false]") + -- table.insert(formspec, "style_type[button;bgcolor=#a37e45]") -- this is used to build a list of all available dialogs for a dropdown menu in edit mode -- (only relevant in edit mode) @@ -880,59 +883,10 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec -- replace $NPC_NAME$ etc. local t = minetest.formspec_escape(yl_speak_up.replace_vars_in_text( (alternate_text or active_dialog.d_text), dialog, pname)) - formspec = { - "formspec_version[1]", - "size[48,28]", - "position[0,0.45]", - "anchor[0,0.45]", - "no_prepend[]", - "bgcolor[#00000000;false]", - -- Container - "container[2,0.75]", - -- Background - - "background[0,0;20,17;yl_speak_up_bg_dialog.png]", - "background[0,18;45,8;yl_speak_up_bg_dialog.png]", - -- Frame Dialog - - "image[-0.35,-0.35;1,1;yl_speak_up_bg_dialog_tl.png]", - "image[-0.35,16.25;1,1;yl_speak_up_bg_dialog_bl.png]", - "image[19.35,-0.35;1,1;yl_speak_up_bg_dialog_tr.png]", - "image[19.35,16.25;1,1;yl_speak_up_bg_dialog_br.png]", - "image[-0.35,0.35;1,19.5;yl_speak_up_bg_dialog_hl.png]", - "image[19.35,0.35;1,19.5;yl_speak_up_bg_dialog_hr.png]", - "image[0.35,-0.35;24.5,1;yl_speak_up_bg_dialog_vt.png]", - "image[0.35,16.25;24.5,1;yl_speak_up_bg_dialog_vb.png]", - -- Frame Options - - "image[-0.35,17.65;1,1;yl_speak_up_bg_dialog_tl.png]", - "image[-0.35,25.35;1,1;yl_speak_up_bg_dialog_bl.png]", - "image[44.35,17.65;1,1;yl_speak_up_bg_dialog_tr.png]", - "image[44.35,25.35;1,1;yl_speak_up_bg_dialog_br.png]", - "image[-0.35,18.35;1,8.5;yl_speak_up_bg_dialog_hl.png]", - "image[44.35,18.35;1,8.5;yl_speak_up_bg_dialog_hr.png]", - "image[0.35,17.65;56.5,1;yl_speak_up_bg_dialog_vt.png]", - "image[0.35,25.35;56.5,1;yl_speak_up_bg_dialog_vb.png]", - -- Upgrade Warning - - upgrade_warning, - -- Dialog - - "label[0.3,0.6;", - minetest.formspec_escape(dialog.n_npc), - "]", - "label[0.3,1.8;", - minetest.formspec_escape(dialog.n_description), - "]", - "image[15.5,0.5;4,4;", - portrait, - "]", - "textarea[0.5,5;19.6,13.5;;;", - t .. "\n", - "]", - "container[0,18]" - } + table.insert(formspec, upgrade_warning) + table.insert(formspec, "textarea[0.5,5;19.6,13.5;;;"..t .. "\n".."]") + table.insert(formspec, "container[0,24]") h = -1 if active_dialog ~= nil and active_dialog.d_options ~= nil then