used table.concat to insert yl_speak_up.show_fs_simple_deco instead of just string concatination

This commit is contained in:
Sokomine 2023-12-18 03:02:56 +01:00
parent afe47c3908
commit 0f0593100e
4 changed files with 26 additions and 23 deletions

View File

@ -250,11 +250,12 @@ yl_speak_up.get_fs_do_trade_simple = function(player, trade_id)
end end
-- the common formspec, shared by actual trade and configuration -- the common formspec, shared by actual trade and configuration
-- no listring here as that would make things more complicated -- no listring here as that would make things more complicated
local formspec = -- "size[8.5,8]".. local formspec = table.concat({ -- "size[8.5,8]"..
yl_speak_up.show_fs_simple_deco(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:]".. "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,3.85;8,1;]",
"list[current_player;main;0.2,5.08;8,3;8]" "list[current_player;main;0.2,5.08;8,3;8]"
}, "")
-- configuration of a new trade happens here -- configuration of a new trade happens here
if(not(trade.player_gives) or not(trade.npc_gives) or trade.edit_trade) then if(not(trade.player_gives) or not(trade.npc_gives) or trade.edit_trade) then

View File

@ -2,21 +2,22 @@
yl_speak_up.get_fs_player_offers_item = function(player, param) yl_speak_up.get_fs_player_offers_item = function(player, param)
local pname = player:get_player_name() local pname = player:get_player_name()
local dialog = yl_speak_up.speak_to[pname].dialog local dialog = yl_speak_up.speak_to[pname].dialog
return yl_speak_up.show_fs_simple_deco(8.5, 8).. 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,3.85;8,1;]",
"list[current_player;main;0.2,5.08;8,3;8]".. "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[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]".. "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".. "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".. "tooltip[finished_action;Click here once you have placed the item in\n"..
"the waiting slot.]".. "the waiting slot.]",
"label[1.5,0.7;What do you want to give to ".. "label[1.5,0.7;What do you want to give to ",
minetest.formspec_escape(dialog.n_npc or "- ? -").."?]".. minetest.formspec_escape(dialog.n_npc or "- ? -"), "?]",
-- the npc_wants inventory slot can be used here as well -- 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.]" "label[1.5,2.7;Insert the item here and click on \"Give\" to proceed.]"
}, "")
end end
@ -63,8 +64,8 @@ yl_speak_up.input_player_offers_item = function(player, formname, fields)
-- show a message to the player -- show a message to the player
yl_speak_up.show_fs(player, "msg", { yl_speak_up.show_fs(player, "msg", {
input_to = "yl_speak_up:player_offers_item", input_to = "yl_speak_up:player_offers_item",
formspec = yl_speak_up.show_fs_simple_deco(8, 2.5).. formspec = table.concat({yl_speak_up.show_fs_simple_deco(8, 2.5),
"label[0.5,0.5;".. "label[0.5,0.5;",
error_msg.."]".. error_msg, "]"}, ""),
"button[3.5,1.5;1.5,1.0;back_from_error_msg;Back]"}) "button[3.5,1.5;1.5,1.0;back_from_error_msg;Back]"})
end end

View File

@ -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 pname = player:get_player_name()
local trade_inv = minetest.get_inventory({type="detached", name="yl_speak_up_player_"..pname}) local trade_inv = minetest.get_inventory({type="detached", name="yl_speak_up_player_"..pname})
if(not(trade_inv:is_empty("npc_wants"))) then if(not(trade_inv:is_empty("npc_wants"))) then
return "formspec_version[1]".. return table.concat({"formspec_version[1]",
yl_speak_up.show_fs_simple_deco(8, 2.5).. yl_speak_up.show_fs_simple_deco(8, 2.5),
"label[0.5,0.5;".. "label[0.5,0.5;",
minetest.formspec_escape(dialog.n_npc or "- ? -").. minetest.formspec_escape(dialog.n_npc or "- ? -"),
" does not seem to be intrested in that.\n".. " does not seem to be intrested in that.\n"..
"Please take your item back and try something else.]".. "Please take your item back and try something else.]"..
"button[3.5,1.5;1.5,1.0;show_player_offers_item;Ok]" "button[3.5,1.5;1.5,1.0;show_player_offers_item;Ok]"
}, "")
end end
end end

View File

@ -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 -- the common formspec, shared by actual trade and configuration
-- no listring here as that would make things more complicated -- no listring here as that would make things more complicated
local formspec = { -- "size[8.5,8]".. local formspec = { -- "size[8.5,8]"..
yl_speak_up.show_fs_simple_deco(10, 8.8).. yl_speak_up.show_fs_simple_deco(10, 8.8),
"container[0.75,0]".. "container[0.75,0]",
"label[4.35,1.4;", npc_name, " sells:]", "label[4.35,1.4;", npc_name, " sells:]",
"list[current_player;main;0.2,4.55;8,1;]", "list[current_player;main;0.2,4.55;8,1;]",
"list[current_player;main;0.2,5.78;8,3;8]", "list[current_player;main;0.2,5.78;8,3;8]",