From d9602eb3bc957331b241035b0b15e68f6ddb2982 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 19 Sep 2017 19:40:54 +0200 Subject: [PATCH] Close chest formspec if chest is destroyed --- mods/ITEMS/mcl_chests/init.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index f4b4b1d34..982c6669a 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -108,6 +108,13 @@ minetest.register_node("mcl_chests:"..basename, { on_rightclick_addendum(pos, node, clicker) end end, + + on_destruct = function(pos) + local players = minetest.get_connected_players() + for p=1, #players do + minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) + end + end, mesecons = mesecons, }) @@ -124,6 +131,12 @@ minetest.register_node("mcl_chests:"..basename.."_left", { if n.name == "mcl_chests:"..basename then return end + + local players = minetest.get_connected_players() + for p=1, #players do + minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) + end + local param2 = n.param2 local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "left") if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_right" then @@ -232,6 +245,12 @@ minetest.register_node("mcl_chests:"..basename.."_right", { if n.name == "mcl_chests:"..basename then return end + + local players = minetest.get_connected_players() + for p=1, #players do + minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..basename.."_"..pos.x.."_"..pos.y.."_"..pos.z) + end + local param2 = n.param2 local p = mcl_util.get_double_container_neighbor_pos(pos, param2, "right") if not p or minetest.get_node(p).name ~= "mcl_chests:"..basename.."_left" then