From 0f0593100ee0dbbc27232b49a8f8fdfaf2dac5a6 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 18 Dec 2023 03:02:56 +0100 Subject: [PATCH] used table.concat to insert yl_speak_up.show_fs_simple_deco instead of just string concatination --- fs/fs_do_trade_simple.lua | 9 +++++---- fs/fs_player_offers_item.lua | 27 ++++++++++++++------------- fs/fs_talkdialog.lua | 9 +++++---- fs/fs_trade_via_buy_button.lua | 4 ++-- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/fs/fs_do_trade_simple.lua b/fs/fs_do_trade_simple.lua index 540ed5c..45ae33c 100644 --- a/fs/fs_do_trade_simple.lua +++ b/fs/fs_do_trade_simple.lua @@ -250,11 +250,12 @@ yl_speak_up.get_fs_do_trade_simple = function(player, trade_id) end -- the common formspec, shared by actual trade and configuration -- no listring here as that would make things more complicated - local formspec = -- "size[8.5,8]".. - yl_speak_up.show_fs_simple_deco(8.5, 8).. - "label[4.35,0.7;"..minetest.formspec_escape(trade.npc_name).." sells:]".. - "list[current_player;main;0.2,3.85;8,1;]".. + local formspec = table.concat({ -- "size[8.5,8]".. + yl_speak_up.show_fs_simple_deco(8.5, 8), + "label[4.35,0.7;", minetest.formspec_escape(trade.npc_name), " sells:]", + "list[current_player;main;0.2,3.85;8,1;]", "list[current_player;main;0.2,5.08;8,3;8]" + }, "") -- configuration of a new trade happens here if(not(trade.player_gives) or not(trade.npc_gives) or trade.edit_trade) then diff --git a/fs/fs_player_offers_item.lua b/fs/fs_player_offers_item.lua index bd4ee49..b5e97b4 100644 --- a/fs/fs_player_offers_item.lua +++ b/fs/fs_player_offers_item.lua @@ -2,21 +2,22 @@ yl_speak_up.get_fs_player_offers_item = function(player, param) local pname = player:get_player_name() local dialog = yl_speak_up.speak_to[pname].dialog - return yl_speak_up.show_fs_simple_deco(8.5, 8).. - "list[current_player;main;0.2,3.85;8,1;]".. - "list[current_player;main;0.2,5.08;8,3;8]".. - "button[0.2,0.0;2.0,0.9;back_to_talk;Back to talk]".. - "button[4.75,1.6;1.5,0.9;finished_action;Give]".. + return table.concat({yl_speak_up.show_fs_simple_deco(8.5, 8), + "list[current_player;main;0.2,3.85;8,1;]", + "list[current_player;main;0.2,5.08;8,3;8]", + "button[0.2,0.0;2.0,0.9;back_to_talk;Back to talk]", + "button[4.75,1.6;1.5,0.9;finished_action;Give]", "tooltip[back_to_talk;Click here if you're finished with giving\n".. - "items to the NPC.]".. + "items to the NPC.]", "tooltip[finished_action;Click here once you have placed the item in\n".. - "the waiting slot.]".. - "label[1.5,0.7;What do you want to give to ".. - minetest.formspec_escape(dialog.n_npc or "- ? -").."?]".. + "the waiting slot.]", + "label[1.5,0.7;What do you want to give to ", + minetest.formspec_escape(dialog.n_npc or "- ? -"), "?]", -- the npc_wants inventory slot can be used here as well - "list[detached:yl_speak_up_player_"..pname..";npc_wants;3.25,1.5;1,1;]" .. + "list[detached:yl_speak_up_player_", pname, ";npc_wants;3.25,1.5;1,1;]", "label[1.5,2.7;Insert the item here and click on \"Give\" to proceed.]" + }, "") end @@ -63,8 +64,8 @@ yl_speak_up.input_player_offers_item = function(player, formname, fields) -- show a message to the player yl_speak_up.show_fs(player, "msg", { input_to = "yl_speak_up:player_offers_item", - formspec = yl_speak_up.show_fs_simple_deco(8, 2.5).. - "label[0.5,0.5;".. - error_msg.."]".. + formspec = table.concat({yl_speak_up.show_fs_simple_deco(8, 2.5), + "label[0.5,0.5;", + error_msg, "]"}, ""), "button[3.5,1.5;1.5,1.0;back_from_error_msg;Back]"}) end diff --git a/fs/fs_talkdialog.lua b/fs/fs_talkdialog.lua index 4dd8470..e61f32e 100644 --- a/fs/fs_talkdialog.lua +++ b/fs/fs_talkdialog.lua @@ -908,13 +908,14 @@ yl_speak_up.get_fs_talkdialog = function(player, n_id, d_id, alternate_text, rec local pname = player:get_player_name() local trade_inv = minetest.get_inventory({type="detached", name="yl_speak_up_player_"..pname}) if(not(trade_inv:is_empty("npc_wants"))) then - return "formspec_version[1]".. - yl_speak_up.show_fs_simple_deco(8, 2.5).. - "label[0.5,0.5;".. - minetest.formspec_escape(dialog.n_npc or "- ? -").. + return table.concat({"formspec_version[1]", + yl_speak_up.show_fs_simple_deco(8, 2.5), + "label[0.5,0.5;", + minetest.formspec_escape(dialog.n_npc or "- ? -"), " does not seem to be intrested in that.\n".. "Please take your item back and try something else.]".. "button[3.5,1.5;1.5,1.0;show_player_offers_item;Ok]" + }, "") end end diff --git a/fs/fs_trade_via_buy_button.lua b/fs/fs_trade_via_buy_button.lua index 42e5dd9..f7273bc 100644 --- a/fs/fs_trade_via_buy_button.lua +++ b/fs/fs_trade_via_buy_button.lua @@ -240,8 +240,8 @@ yl_speak_up.get_fs_trade_via_buy_button = function(player, trade_id) -- the common formspec, shared by actual trade and configuration -- no listring here as that would make things more complicated local formspec = { -- "size[8.5,8]".. - yl_speak_up.show_fs_simple_deco(10, 8.8).. - "container[0.75,0]".. + yl_speak_up.show_fs_simple_deco(10, 8.8), + "container[0.75,0]", "label[4.35,1.4;", npc_name, " sells:]", "list[current_player;main;0.2,4.55;8,1;]", "list[current_player;main;0.2,5.78;8,3;8]",