forked from mtcontrib/bitchange
shop: Add listring
This commit is contained in:
parent
db64a14cdc
commit
498d97a8bc
30
shop.lua
30
shop.lua
@ -8,6 +8,7 @@ local exchange_shop = {}
|
|||||||
local function get_exchange_shop_formspec(number,pos,title)
|
local function get_exchange_shop_formspec(number,pos,title)
|
||||||
local formspec = ""
|
local formspec = ""
|
||||||
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
local name = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||||
|
|
||||||
if number == 1 then
|
if number == 1 then
|
||||||
-- customer
|
-- customer
|
||||||
formspec = ("size[8,9;]"..
|
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.5;Ejected items:]"..
|
||||||
"label[0.7,3.8;(Remove me!)]"..
|
"label[0.7,3.8;(Remove me!)]"..
|
||||||
"list["..name..";cust_ej;3,3.5;4,1;]"..
|
"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
|
elseif number == 2 or number == 3 then
|
||||||
-- owner
|
-- owner
|
||||||
formspec = ("size[11,10;]"..
|
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!)]"..
|
"label[0.3,3.5;Ejected items: (Remove me!)]"..
|
||||||
"list["..name..";custm_ej;0,4;4,1;]"..
|
"list["..name..";custm_ej;0,4;4,1;]"..
|
||||||
"label[6,0;You are viewing:]"..
|
"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
|
if number == 2 then
|
||||||
formspec = (formspec.."button[8.5,0.2;2.5,0.5;vstock;Customers stock]"..
|
formspec = (formspec..
|
||||||
"list["..name..";custm;6,1;5,4;]")
|
"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
|
else
|
||||||
formspec = (formspec.."button[8.5,0.2;2.5,0.5;vcustm;Your stock]"..
|
formspec = (formspec..
|
||||||
"list["..name..";stock;6,1;5,4;]")
|
"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
|
end
|
||||||
formspec = (formspec..
|
formspec = (formspec..
|
||||||
"label[1,5;Use (E) + (Right click) for customer interface]"..
|
"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
|
return
|
||||||
end
|
end
|
||||||
local player_name = sender:get_player_name()
|
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 pos = exchange_shop[player_name]
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local title = meta:get_string("title") or ""
|
local title = meta:get_string("title") or ""
|
||||||
@ -108,7 +122,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
else
|
else
|
||||||
meta:set_string("infotext", "Exchange shop (owned by "..shop_owner..")")
|
meta:set_string("infotext", "Exchange shop (owned by "..shop_owner..")")
|
||||||
end
|
end
|
||||||
meta:set_string("title", fields.title)
|
meta:set_string("title", minetest.formspec_escape(fields.title))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user