mirror of
https://codeberg.org/usrib/emeraldbank.git
synced 2024-08-18 20:34:04 +02:00
check_empty func do not show formspec
This commit is contained in:
parent
560cc4a7a7
commit
41fa30ee22
20
shop.lua
20
shop.lua
@ -102,7 +102,7 @@ local function set_item(pos, stack, player)
|
||||
core.show_formspec(player:get_player_name(), formspec_prefix..core.pos_to_string(pos), emeraldbank.get_shop_fs(pos, player) )
|
||||
end
|
||||
|
||||
local function check_empty(pos, player)
|
||||
local function check_empty(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local count = meta:get_int("count")
|
||||
@ -115,7 +115,6 @@ local function check_empty(pos, player)
|
||||
else
|
||||
swap_shop(pos)
|
||||
end
|
||||
core.show_formspec(player:get_player_name(), formspec_prefix..core.pos_to_string(pos), emeraldbank.get_shop_fs(pos, player) )
|
||||
end
|
||||
|
||||
local function get_stonks(pos, player)
|
||||
@ -165,15 +164,19 @@ end
|
||||
|
||||
local function on_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
set_item(pos, stack, player)
|
||||
check_empty(pos, player)
|
||||
check_empty(pos)
|
||||
--core.show_formspec(player:get_player_name(), formspec_prefix..core.pos_to_string(pos), emeraldbank.get_shop_fs(pos, player) )
|
||||
end
|
||||
|
||||
local function on_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
check_empty(pos, player)
|
||||
check_empty(pos)
|
||||
--core.show_formspec(player:get_player_name(), formspec_prefix..core.pos_to_string(pos), emeraldbank.get_shop_fs(pos, player) )
|
||||
|
||||
end
|
||||
|
||||
local function on_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
check_empty(pos, player)
|
||||
check_empty(pos)
|
||||
core.show_formspec(player:get_player_name(), formspec_prefix..core.pos_to_string(pos), emeraldbank.get_shop_fs(pos, player) )
|
||||
end
|
||||
|
||||
|
||||
@ -182,6 +185,7 @@ local function on_timer(pos, elapsed)
|
||||
local owner = meta:get_string("owner")
|
||||
local is_online = core.player_exists(owner)
|
||||
core.get_node_timer(pos):start(shop_timer)
|
||||
check_empty(pos)
|
||||
if is_online then
|
||||
local player = core.get_player_by_name(owner)
|
||||
if not player or player.is_fake_player then return end
|
||||
@ -279,7 +283,7 @@ core.register_on_player_receive_fields(function(sender, formname, fields)
|
||||
if fields.count and string.find(fields.count, "^[0-9]+$") then
|
||||
if new_count >= 1 and new_count <= 64 and new_count ~= meta:get_int("count") then
|
||||
meta:set_int("count", new_count)
|
||||
check_empty(pos, sender)
|
||||
check_empty(pos)
|
||||
end
|
||||
end
|
||||
|
||||
@ -315,8 +319,8 @@ core.register_on_player_receive_fields(function(sender, formname, fields)
|
||||
emeraldbank.add_emeralds(sender, -old_price)
|
||||
meta:set_int("stonks", meta:get_int("stonks")+old_price)
|
||||
core.chat_send_player(name, S("Exchanged!"))
|
||||
check_empty(pos, sender) --this func already shows formspec, so I comment it bellow
|
||||
--core.show_formspec(sender:get_player_name(), formspec_prefix..core.pos_to_string(pos), emeraldbank.get_shop_fs(pos, sender) )
|
||||
check_empty(pos)
|
||||
core.show_formspec(sender:get_player_name(), formspec_prefix..core.pos_to_string(pos), emeraldbank.get_shop_fs(pos, sender) )
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user