Commit 45931b87 authored by SmallJoker's avatar SmallJoker
Browse files

It needed an update - there's it.

parent 808593bf
......@@ -87,7 +87,9 @@ local function get_exchange_shop_tube_config(mode)
end
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 pos = exchange_shop[player_name]
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."
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
local player_has_space = true
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."
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
local fully_exchanged = true
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
minetest.show_formspec(sender:get_player_name(),"bitchange:shop_formspec",get_exchange_shop_formspec(2, pos, title))
end
end
end)
minetest.register_node("bitchange:shop", {
......@@ -268,7 +269,9 @@ minetest.register_node("bitchange:shop", {
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
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
else
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
view = 1
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,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.get_meta(pos)
if (not bitchange_has_access(meta:get_string("owner"), player:get_player_name())) then
return 0
end
if bitchange_has_access(meta:get_string("owner"), player:get_player_name()) then
return count
end
return 0
end,
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)
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()
......@@ -306,6 +316,9 @@ minetest.register_node("bitchange:shop", {
return 0
end,
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)
if (bitchange_has_access(meta:get_string("owner"), player:get_player_name()) or (listname == "cust_ej")) then
return stack:get_count()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment