summaryrefslogtreecommitdiff
path: root/admin.lua
diff options
context:
space:
mode:
Diffstat (limited to 'admin.lua')
-rw-r--r--admin.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/admin.lua b/admin.lua
index defe809..e264f11 100644
--- a/admin.lua
+++ b/admin.lua
@@ -117,3 +117,36 @@ minetest.register_abm({
end
end
})
+
+
+-- show protection areas of nearby protectors owned by you (thanks agaran)
+minetest.register_chatcommand("protector_show", {
+ params = "",
+ description = "Show protected areas of your nearby protectors",
+ privs = {},
+ func = function(name, param)
+
+ local player = minetest.get_player_by_name(name)
+ local pos = player:getpos()
+ local r = protector.radius -- max protector range.
+
+ -- find the protector nodes
+ local pos = minetest.find_nodes_in_area(
+ {x = pos.x - r, y = pos.y - r, z = pos.z - r},
+ {x = pos.x + r, y = pos.y + r, z = pos.z + r},
+ {"protector:protect", "protector:protect2"})
+
+ local meta, owner
+
+ -- show a maximum of 5 protected areas only
+ for n = 1, math.min(#pos, 5) do
+
+ meta = minetest.get_meta(pos[n])
+ owner = meta:get_string("owner") or ""
+
+ if owner == name then
+ minetest.add_entity(pos[n], "protector:display")
+ end
+ end
+ end
+})