From a2e803d5226177d46d544699ee698b83d0b6b165 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Wed, 24 Oct 2018 13:59:56 +0100 Subject: [PATCH] remove protector field when dug --- README.md | 1 + init.lua | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 3c0016f..132d54d 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Change log: - 2.4 - Update to newer functions, Minetest 0.4.16 needed to run now. - 2.5 - Added HUD text to show when player is inside a protected area (updates every 5 seconds) - 2.6 - Add protection against CSM tampering, updated Intllib support (thanks codexp), tweaked block textures +- 2.7 - Remove protection field entity when protector has been dug Lucky Blocks: 10 diff --git a/init.lua b/init.lua index 90e5725..c9dd9d2 100644 --- a/init.lua +++ b/init.lua @@ -430,6 +430,13 @@ minetest.register_node("protector:protect", { end, on_blast = function() end, + + after_destruct = function(pos, oldnode) + local objects = minetest.get_objects_inside_radius(pos, 0.5) + for _, v in ipairs(objects) do + v:remove() + end + end, }) minetest.register_craft({ @@ -514,6 +521,13 @@ minetest.register_node("protector:protect2", { end, on_blast = function() end, + + after_destruct = function(pos, oldnode) + local objects = minetest.get_objects_inside_radius(pos, 0.5) + for _, v in ipairs(objects) do + v:remove() + end + end, }) -- recipes to switch between protectors