forked from your-land-mirror/yl_speak_up
broke long formspec strings into table.concat lists
This commit is contained in:
parent
42c3751966
commit
35fa4e9774
@ -59,33 +59,35 @@ yl_speak_up.get_fs_action_npc_gives = function(player, param)
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
-- it's not the fault of the player that the NPC doesn't have the item;
|
||||
-- so tell him that (the action will still fail)
|
||||
return "size[7,2.0]"..
|
||||
"label[0.2,-0.2;"..
|
||||
minetest.formspec_escape(dialog.n_npc or "- ? -")..
|
||||
return table.concat({"size[7,2.0]"..
|
||||
"label[0.2,-0.2;",
|
||||
minetest.formspec_escape(dialog.n_npc or "- ? -"),
|
||||
" is very sorry:\n"..
|
||||
"The item intended for you is currently unavailable.\n"..
|
||||
"Please come back later!]"..
|
||||
"button[2,1.5;1.5,0.9;npc_does_not_have_item;Back]"
|
||||
"button[2,1.5;1.5,0.9;npc_does_not_have_item;Back]"}, "")
|
||||
end
|
||||
end
|
||||
local pname = player:get_player_name()
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
return "size[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;Done]"..
|
||||
return table.concat({"size[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;Done]",
|
||||
|
||||
"tooltip[back_to_talk;Click here if you don't want to (or can't)\n"..
|
||||
"take the offered item.]"..
|
||||
"tooltip[finished_action;Click here once you have taken the item and\n"..
|
||||
"stored it in your inventory.]"..
|
||||
"label[1.5,0.7;"..minetest.formspec_escape(dialog.n_npc or "- ? -")..
|
||||
" offers to you:]"..
|
||||
"tooltip[back_to_talk;Click here if you don't want to (or can't)\n",
|
||||
"take the offered item.]",
|
||||
"tooltip[finished_action;Click here once you have taken the item and\n",
|
||||
"stored it in your inventory.]",
|
||||
"label[1.5,0.7;",
|
||||
minetest.formspec_escape(dialog.n_npc or "- ? -"),
|
||||
" offers to you:]",
|
||||
-- unlike the npc_gives slot - which is used for setting up the NPC - the
|
||||
-- npc_gives slot does not allow putting something in
|
||||
"list[detached:yl_speak_up_player_"..pname..";npc_gives;3.25,1.5;1,1;]" ..
|
||||
"list[detached:yl_speak_up_player_"..pname..";npc_gives;3.25,1.5;1,1;]" ,
|
||||
"label[1.5,2.7;Take the offered item and click on \"Done\" to proceed.]"
|
||||
}, "")
|
||||
end
|
||||
|
||||
|
||||
|
@ -38,20 +38,24 @@ end
|
||||
yl_speak_up.get_fs_action_npc_wants = function(player, param)
|
||||
local pname = player:get_player_name()
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
return "size[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;Done]"..
|
||||
return table.concat({"size[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;Done]",
|
||||
|
||||
"tooltip[back_to_talk;Click here if you don't know what item the\n"..
|
||||
"NPC wants or don't have the desired item.]"..
|
||||
"tooltip[finished_action;Click here once you have placed the item in\n"..
|
||||
"the waiting slot.]"..
|
||||
"label[1.5,0.7;"..minetest.formspec_escape(dialog.n_npc or "- ? -")..
|
||||
" expects something from you:]"..
|
||||
"list[detached:yl_speak_up_player_"..pname..";npc_wants;3.25,1.5;1,1;]" ..
|
||||
"tooltip[back_to_talk;Click here if you don't know what item the\n",
|
||||
"NPC wants or don't have the desired item.]",
|
||||
"tooltip[finished_action;Click here once you have placed the item in\n",
|
||||
"the waiting slot.]",
|
||||
"label[1.5,0.7;",
|
||||
minetest.formspec_escape(dialog.n_npc or "- ? -"),
|
||||
" expects something from you:]",
|
||||
"list[detached:yl_speak_up_player_",
|
||||
pname,
|
||||
";npc_wants;3.25,1.5;1,1;]",
|
||||
"label[1.5,2.7;Insert the right item and click on \"Done\" to proceed.]"
|
||||
}, "")
|
||||
end
|
||||
|
||||
|
||||
|
@ -44,31 +44,40 @@ yl_speak_up.get_fs_add_trade_simple = function(player, trade_id)
|
||||
if(trade_id and trade_id == "new") then
|
||||
delete_button = ""
|
||||
end
|
||||
return "size[8.5,9]"..
|
||||
"label[4.35,0.8;"..minetest.formspec_escape(dialog.n_npc).." sells:]"..
|
||||
"list[current_player;main;0.2,4.85;8,1;]"..
|
||||
"list[current_player;main;0.2,6.08;8,3;8]"..
|
||||
return table.concat({"size[8.5,9]",
|
||||
"label[4.35,0.8;",
|
||||
minetest.formspec_escape(dialog.n_npc),
|
||||
" sells:]",
|
||||
"list[current_player;main;0.2,4.85;8,1;]",
|
||||
"list[current_player;main;0.2,6.08;8,3;8]",
|
||||
-- show the second slot of the setup inventory in the detached player's inv
|
||||
"list[detached:yl_speak_up_player_"..pname..";setup;2,1.5;1,1;]"..
|
||||
"list[detached:yl_speak_up_player_",
|
||||
pname,
|
||||
";setup;2,1.5;1,1;]",
|
||||
-- show the second slot of said inventory
|
||||
"list[detached:yl_speak_up_player_"..pname..";setup;5,1.5;1,1;1]"..
|
||||
"label[0.5,0.0;Configure trade with "..minetest.formspec_escape(dialog.n_npc)..":]"..
|
||||
"label[1.5,0.8;The customer pays:]"..
|
||||
"label[1.5,3.8;Put items in the two slots and click on \"Store trade\".]"..
|
||||
"label[1.5,4.2;You will get your items back when storing the trade.]"..
|
||||
"list[detached:yl_speak_up_player_",
|
||||
pname,
|
||||
";setup;5,1.5;1,1;1]",
|
||||
"label[0.5,0.0;Configure trade with ",
|
||||
minetest.formspec_escape(dialog.n_npc),
|
||||
":]",
|
||||
"label[1.5,0.8;The customer pays:]",
|
||||
"label[1.5,3.8;Put items in the two slots and click on \"Store trade\".]",
|
||||
"label[1.5,4.2;You will get your items back when storing the trade.]",
|
||||
-- annoyingly, the height value no longer works :-(
|
||||
"label[0.2,2.5;Item\nname:]"..
|
||||
"field[1.5,3.2;3,0.2;item_name_price;;]"..
|
||||
"label[4.35,2.5;If you don't have the item you\n"..
|
||||
"want to buy, then enter its item\n"..
|
||||
"name (i.e. default:diamond) here.]"..
|
||||
"button[0.2,1.6;1.0,0.9;abort_trade_simple;Abort]"..
|
||||
delete_button..
|
||||
"button[6.2,1.6;2.0,0.9;store_trade_simple;Store trade]"..
|
||||
"tooltip[store_trade_simple;Click here to store this as a new trade. Your\n"..
|
||||
"items will be returned to you and the trade will\n"..
|
||||
"will be shown the way the customer can see it.]"..
|
||||
"label[0.2,2.5;Item\nname:]",
|
||||
"field[1.5,3.2;3,0.2;item_name_price;;]",
|
||||
"label[4.35,2.5;If you don't have the item you\n",
|
||||
"want to buy, then enter its item\n",
|
||||
"name (i.e. default:diamond) here.]",
|
||||
"button[0.2,1.6;1.0,0.9;abort_trade_simple;Abort]",
|
||||
delete_button,
|
||||
"button[6.2,1.6;2.0,0.9;store_trade_simple;Store trade]",
|
||||
"tooltip[store_trade_simple;Click here to store this as a new trade. Your\n",
|
||||
"items will be returned to you and the trade will\n",
|
||||
"will be shown the way the customer can see it.]",
|
||||
"tooltip[abort_trade_simple;Abort setting up this new trade.]"
|
||||
}, "")
|
||||
end
|
||||
|
||||
-- the player wants to add a simple trade; handle formspec input
|
||||
|
@ -392,21 +392,36 @@ yl_speak_up.get_fs_do_trade_simple = function(player, trade_id)
|
||||
trades_done = "Traded: "..tostring(yl_speak_up.trade[pname].trade_done).." time(s)"
|
||||
end
|
||||
|
||||
return formspec..
|
||||
"label[2.5,0.0;Trading with "..minetest.formspec_escape(trade.npc_name).."]"..
|
||||
"label[1.5,0.7;You pay:]"..
|
||||
return table.concat({formspec,
|
||||
"label[2.5,0.0;Trading with ",
|
||||
minetest.formspec_escape(trade.npc_name),
|
||||
"]",
|
||||
"label[1.5,0.7;You pay:]",
|
||||
-- show images of price and what is sold so that the player knows what
|
||||
-- it costs and what he will get even if the trade is not possible at
|
||||
-- that moment
|
||||
"item_image[2.1,1.2;0.8,0.8;"..tostring(trade.player_gives).."]"..
|
||||
"item_image[5.1,1.2;0.8,0.8;"..tostring(trade.npc_gives).."]"..
|
||||
"image[3.5,2.0;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
|
||||
"item_image[2.1,1.2;0.8,0.8;",
|
||||
tostring(trade.player_gives),
|
||||
"]",
|
||||
"item_image[5.1,1.2;0.8,0.8;",
|
||||
tostring(trade.npc_gives),
|
||||
"]",
|
||||
"image[3.5,2.0;1,1;gui_furnace_arrow_bg.png^[transformR270]",
|
||||
-- show the pay slot from the detached player's trade inventory
|
||||
"list[detached:yl_speak_up_player_"..pname..";pay;2,2.0;1,1;]" ..
|
||||
"list[detached:yl_speak_up_player_",
|
||||
pname,
|
||||
";pay;2,2.0;1,1;]",
|
||||
-- show the buy slot from the same inventory
|
||||
"list[detached:yl_speak_up_player_"..pname..";buy;5,2.0;1,1;]" ..
|
||||
"label[1.5,3.0;"..trade_possible_msg.."]"..
|
||||
"label[6.0,1.5;"..trades_done.."]"
|
||||
"list[detached:yl_speak_up_player_",
|
||||
pname,
|
||||
";buy;5,2.0;1,1;]",
|
||||
"label[1.5,3.0;",
|
||||
trade_possible_msg,
|
||||
"]",
|
||||
"label[6.0,1.5;",
|
||||
trades_done,
|
||||
"]"
|
||||
}, "")
|
||||
end
|
||||
|
||||
|
||||
|
@ -45,16 +45,24 @@ yl_speak_up.get_fs_inventory = function(player)
|
||||
"button_exit[2,1.5;1,0.9;exit;Exit]"
|
||||
end
|
||||
|
||||
return "size[12,11]" ..
|
||||
"label[2,-0.2;Inventory of "..minetest.formspec_escape(dialog.n_npc)..
|
||||
" (ID: "..tostring(n_id).."):]"..
|
||||
"list[detached:yl_speak_up_npc_"..tostring(n_id)..";npc_main;0,0.3;12,6;]" ..
|
||||
"list[current_player;main;2,7.05;8,1;]" ..
|
||||
"list[current_player;main;2,8.28;8,3;8]" ..
|
||||
"listring[detached:yl_speak_up_npc_"..tostring(n_id)..";npc_main]" ..
|
||||
"listring[current_player;main]" ..
|
||||
"button[3.5,6.35;5,0.6;inventory_show_tradelist;Show trade list trades (player view)]"..
|
||||
return table.concat({"size[12,11]",
|
||||
"label[2,-0.2;Inventory of ",
|
||||
minetest.formspec_escape(dialog.n_npc),
|
||||
" (ID: ",
|
||||
tostring(n_id),
|
||||
"):]",
|
||||
"list[detached:yl_speak_up_npc_",
|
||||
tostring(n_id),
|
||||
";npc_main;0,0.3;12,6;]",
|
||||
"list[current_player;main;2,7.05;8,1;]",
|
||||
"list[current_player;main;2,8.28;8,3;8]",
|
||||
"listring[detached:yl_speak_up_npc_",
|
||||
tostring(n_id),
|
||||
";npc_main]",
|
||||
"listring[current_player;main]",
|
||||
"button[3.5,6.35;5,0.6;inventory_show_tradelist;Show trade list trades (player view)]",
|
||||
"button[10.0,10.4;2,0.9;back_from_inventory;Back]"
|
||||
}, "")
|
||||
end
|
||||
|
||||
|
||||
|
@ -76,29 +76,29 @@ yl_speak_up.get_fs_trade_limit = function(player, selected)
|
||||
|
||||
-- all items for which limitations might possibly be needed have been collected;
|
||||
-- now display them
|
||||
local formspec = {'size[18,12]'..
|
||||
'button[0.5,11.1;17,0.8;back;Back]'..
|
||||
'label[7.0,0.5;List of trade limits]'..
|
||||
local formspec = {'size[18,12]',
|
||||
'button[0.5,11.1;17,0.8;back;Back]',
|
||||
'label[7.0,0.5;List of trade limits]',
|
||||
'label[0.5,1.0;If you do not set any limits, your NPC will buy and sell as many '..
|
||||
'items as his inventory allows.\n'..
|
||||
'items as his inventory allows.\n',
|
||||
'If you set \'Will sell if more than this\', your NPC '..
|
||||
'will only sell if he will have enough left after the trade,\n'..
|
||||
'will only sell if he will have enough left after the trade,\n',
|
||||
'and if you set \'Will buy if less than this\', he will '..
|
||||
'only buy items as long as he will not end up with more than '..
|
||||
'this.]'..
|
||||
'tablecolumns[' ..
|
||||
'text,align=left;'..
|
||||
'color;text,align=right;'..
|
||||
'color;text,align=center;'..
|
||||
'text,align=right;'..
|
||||
'color;text,align=center;'..
|
||||
'text,align=right;'..
|
||||
'color;text,align=left]'..
|
||||
'table[0.1,2.3;17.8,8.5;edit_trade_limit;'..
|
||||
'Description:,'..
|
||||
'#FFFFFF,NPC has:,'..
|
||||
'#FFFFFF,Will sell if more than this:,,'..
|
||||
'#FFFFFF,Will buy if less than this:,,'..
|
||||
'this.]',
|
||||
'tablecolumns[',
|
||||
'text,align=left;',
|
||||
'color;text,align=right;',
|
||||
'color;text,align=center;',
|
||||
'text,align=right;',
|
||||
'color;text,align=center;',
|
||||
'text,align=right;',
|
||||
'color;text,align=left]',
|
||||
'table[0.1,2.3;17.8,8.5;edit_trade_limit;',
|
||||
'Description:,',
|
||||
'#FFFFFF,NPC has:,',
|
||||
'#FFFFFF,Will sell if more than this:,,',
|
||||
'#FFFFFF,Will buy if less than this:,,',
|
||||
'#EEEEEE,Item string:,'
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user