allow to enter item name of price item instead of an example item
This commit is contained in:
parent
9358a27b03
commit
b9e6a8a74c
@ -201,18 +201,24 @@ 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,8]"..
|
||||
return "size[8.5,9]"..
|
||||
"label[4.35,0.8;"..minetest.formspec_escape(dialog.n_npc).." sells:]"..
|
||||
"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,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;]"..
|
||||
-- show the second slot of said inventory
|
||||
"list[detached:yl_speak_up_player_"..pname..";setup;5,1.5;1,1;1]"..
|
||||
"label[2.5,0.0;Configure trade with "..minetest.formspec_escape(dialog.n_npc)..":]"..
|
||||
"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,2.8;Put items in the two slots and click on \"Store trade\".]"..
|
||||
"label[1.5,3.2;You will get your items back when storing the trade.]"..
|
||||
"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]"..
|
||||
@ -313,6 +319,11 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields)
|
||||
-- store the new trade
|
||||
if(fields.store_trade_simple) then
|
||||
local error_msg = ""
|
||||
local simulated_pay = false
|
||||
if(pay:is_empty() and fields.item_name_price and fields.item_name_price ~= "") then
|
||||
pay = ItemStack(fields.item_name_price)
|
||||
simulated_pay = true
|
||||
end
|
||||
-- check for error conditions
|
||||
if(pay:is_empty()) then
|
||||
error_msg = "What shall the customer pay?\nWe don't give away stuff for free here!"
|
||||
@ -374,6 +385,10 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields)
|
||||
end
|
||||
-- do not return yet - the items still need to be given back!
|
||||
end
|
||||
-- make sure we don't create items here out of thin air
|
||||
if(simulated_pay) then
|
||||
pay = ItemStack("")
|
||||
end
|
||||
-- show error message (that leads back to this formspec)
|
||||
if(error_msg) then
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
|
Loading…
Reference in New Issue
Block a user