summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-01-21 13:39:49 +0000
committerTenPlus1 <kinsellaja@yahoo.com>2017-01-21 13:39:49 +0000
commit9a8b6c39577b9591e5b4b94254616db8fcb0df2b (patch)
tree23a7ca7498496325d950036b8ff4a95424b47c58
parente7fde19ab591e87925da3fe51a59087bbdef3cdb (diff)
added /protector_show command (thanks agaran)
-rw-r--r--README.md7
-rw-r--r--admin.lua33
2 files changed, 39 insertions, 1 deletions
diff --git a/README.md b/README.md
index df1e6a3..cccb0a2 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ Change log:
(note: previous name can still be used)
2.0 - Added protector placement tool (thanks to Shara) so that players can easily
stand on a protector, face in a direction and it places a new one at a set
- distance to cover protection radius.
+ distance to cover protection radius. Added /protector_show command (thanks agaran)
Lucky Blocks: 6
@@ -76,9 +76,14 @@ replace owner with new name
/protector_replace owner new_owner
reset name list
+
/protector_replace -
+show protected areas of your nearby protectors (max of 5)
+ /protector_show
+
+
The following lines can be added to your minetest.conf file to configure specific features of the mod:
protector_radius = 5
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
+})