forked from mtcontrib/bitchange
It needed an update - there's it.
This commit is contained in:
parent
808593bfba
commit
45931b8718
75
shop.lua
75
shop.lua
@ -87,7 +87,9 @@ local function get_exchange_shop_tube_config(mode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
||||||
if (formname == "bitchange:shop_formspec") then
|
if (formname ~= "bitchange:shop_formspec") then
|
||||||
|
return
|
||||||
|
end
|
||||||
local player_name = sender:get_player_name()
|
local player_name = sender:get_player_name()
|
||||||
local pos = exchange_shop[player_name]
|
local pos = exchange_shop[player_name]
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
@ -154,6 +156,30 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
err_msg = "The 'Owner gives' field can not contain multiple times the same items, contact the shop owner."
|
err_msg = "The 'Owner gives' field can not contain multiple times the same items, contact the shop owner."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if(err_msg == "") then --?shop has space
|
||||||
|
local shop_has_space = true
|
||||||
|
for i, item in pairs(cust_ow) do
|
||||||
|
if (not shop_inv:room_for_item("custm",item)) then
|
||||||
|
shop_has_space = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not shop_has_space) then
|
||||||
|
err_msg = "The stock in the shop is full."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(err_msg == "") then --?shop has items
|
||||||
|
local shop_has_items = true
|
||||||
|
for i, item in pairs(cust_og) do
|
||||||
|
if (not shop_inv:contains_item("stock",item)) then
|
||||||
|
shop_has_items = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if(not shop_has_items) then
|
||||||
|
err_msg = "The shop is empty and can not give you anything."
|
||||||
|
end
|
||||||
|
end
|
||||||
if(err_msg == "") then --?player has space
|
if(err_msg == "") then --?player has space
|
||||||
local player_has_space = true
|
local player_has_space = true
|
||||||
for i, item in pairs(cust_og) do
|
for i, item in pairs(cust_og) do
|
||||||
@ -178,30 +204,6 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
err_msg = "You do not have the needed items."
|
err_msg = "You do not have the needed items."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if(err_msg == "") then --?shop has space
|
|
||||||
local shop_has_space = true
|
|
||||||
for i, item in pairs(cust_ow) do
|
|
||||||
if (not shop_inv:room_for_item("custm",item)) then
|
|
||||||
shop_has_space = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if(not shop_has_space) then
|
|
||||||
err_msg = "Exchange shop: The stock in the shop is full."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if(err_msg == "") then --?shop has items
|
|
||||||
local shop_has_items = true
|
|
||||||
for i, item in pairs(cust_og) do
|
|
||||||
if (not shop_inv:contains_item("stock",item)) then
|
|
||||||
shop_has_items = false
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if(not shop_has_items) then
|
|
||||||
err_msg = "The shop is empty and can not give you anything."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if(err_msg == "") then --?exchange
|
if(err_msg == "") then --?exchange
|
||||||
local fully_exchanged = true
|
local fully_exchanged = true
|
||||||
for i, item in pairs(cust_ow) do
|
for i, item in pairs(cust_ow) do
|
||||||
@ -234,7 +236,6 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
|
|||||||
elseif(fields.vcustm and bitchange_has_access(shop_owner, player_name) and not fields.quit) then
|
elseif(fields.vcustm and bitchange_has_access(shop_owner, player_name) and not fields.quit) then
|
||||||
minetest.show_formspec(sender:get_player_name(),"bitchange:shop_formspec",get_exchange_shop_formspec(2, pos, title))
|
minetest.show_formspec(sender:get_player_name(),"bitchange:shop_formspec",get_exchange_shop_formspec(2, pos, title))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_node("bitchange:shop", {
|
minetest.register_node("bitchange:shop", {
|
||||||
@ -268,7 +269,9 @@ minetest.register_node("bitchange:shop", {
|
|||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
if(inv:is_empty("stock") and inv:is_empty("custm") and inv:is_empty("custm_ej") and inv:is_empty("cust_ow") and inv:is_empty("cust_og") and inv:is_empty("cust_ej")) then
|
if(inv:is_empty("stock") and inv:is_empty("custm") and
|
||||||
|
inv:is_empty("custm_ej") and inv:is_empty("cust_ow") and
|
||||||
|
inv:is_empty("cust_og") and inv:is_empty("cust_ej")) then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(player:get_player_name(), "Can not dig exchange shop, one or multiple stocks are in use.")
|
minetest.chat_send_player(player:get_player_name(), "Can not dig exchange shop, one or multiple stocks are in use.")
|
||||||
@ -289,16 +292,23 @@ minetest.register_node("bitchange:shop", {
|
|||||||
else
|
else
|
||||||
view = 1
|
view = 1
|
||||||
end
|
end
|
||||||
minetest.show_formspec(player_name,"bitchange:shop_formspec",get_exchange_shop_formspec(view, pos, meta:get_string("title")))
|
minetest.show_formspec(player_name, "bitchange:shop_formspec", get_exchange_shop_formspec(view, pos, meta:get_string("title")))
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if (not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
|
if bitchange_has_access(meta:get_string("owner"), player:get_player_name()) then
|
||||||
return 0
|
|
||||||
end
|
|
||||||
return count
|
return count
|
||||||
|
end
|
||||||
|
return 0
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||||
|
if player:get_player_name() == ":pipeworks" then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
if listname == "custm" then
|
||||||
|
minetest.chat_send_player(player:get_player_name(), "Exchange shop: Please press 'Customers stock' and insert your items there.")
|
||||||
|
return 0
|
||||||
|
end
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name()) and (listname ~= "cust_ej") and (listname ~= "custm_ej")) then
|
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name()) and (listname ~= "cust_ej") and (listname ~= "custm_ej")) then
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
@ -306,6 +316,9 @@ minetest.register_node("bitchange:shop", {
|
|||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||||
|
if player:get_player_name() == ":pipeworks" then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name()) or (listname == "cust_ej")) then
|
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name()) or (listname == "cust_ej")) then
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
|
Loading…
Reference in New Issue
Block a user