shop: Add listring

This commit is contained in:
SmallJoker 2016-04-18 20:37:50 +02:00
parent db64a14cdc
commit 498d97a8bc
1 changed files with 27 additions and 13 deletions

View File

@ -8,6 +8,7 @@ local exchange_shop = {}
local function get_exchange_shop_formspec(number,pos,title)
local formspec = ""
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
if number == 1 then
-- customer
formspec = ("size[8,9;]"..
@ -20,7 +21,9 @@ local function get_exchange_shop_formspec(number,pos,title)
"label[0.7,3.5;Ejected items:]"..
"label[0.7,3.8;(Remove me!)]"..
"list["..name..";cust_ej;3,3.5;4,1;]"..
"list[current_player;main;0,5;8,4;]")
"list[current_player;main;0,5;8,4;]"..
"listring["..name..";custm_ej]"..
"listring[current_player;main]")
elseif number == 2 or number == 3 then
-- owner
formspec = ("size[11,10;]"..
@ -34,13 +37,21 @@ local function get_exchange_shop_formspec(number,pos,title)
"label[0.3,3.5;Ejected items: (Remove me!)]"..
"list["..name..";custm_ej;0,4;4,1;]"..
"label[6,0;You are viewing:]"..
"label[6,0.3;(Click to switch)]")
"label[6,0.3;(Click to switch)]"..
"listring["..name..";custm_ej]"..
"listring[current_player;main]")
if number == 2 then
formspec = (formspec.."button[8.5,0.2;2.5,0.5;vstock;Customers stock]"..
"list["..name..";custm;6,1;5,4;]")
formspec = (formspec..
"button[8.5,0.2;2.5,0.5;vstock;Customers stock]"..
"list["..name..";custm;6,1;5,4;]"..
"listring["..name..";custm]"..
"listring[current_player;main]")
else
formspec = (formspec.."button[8.5,0.2;2.5,0.5;vcustm;Your stock]"..
"list["..name..";stock;6,1;5,4;]")
formspec = (formspec..
"button[8.5,0.2;2.5,0.5;vcustm;Your stock]"..
"list["..name..";stock;6,1;5,4;]"..
"listring["..name..";stock]"..
"listring[current_player;main]")
end
formspec = (formspec..
"label[1,5;Use (E) + (Right click) for customer interface]"..
@ -91,7 +102,10 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
return
end
local player_name = sender:get_player_name()
if not exchange_shop[player_name] then return end
if not exchange_shop[player_name] then
return
end
local pos = exchange_shop[player_name]
local meta = minetest.get_meta(pos)
local title = meta:get_string("title") or ""
@ -108,7 +122,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
else
meta:set_string("infotext", "Exchange shop (owned by "..shop_owner..")")
end
meta:set_string("title", fields.title)
meta:set_string("title", minetest.formspec_escape(fields.title))
end
end