added /protector_show command (thanks agaran)
This commit is contained in:
parent
e7fde19ab5
commit
9a8b6c3957
@ -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
|
||||
|
33
admin.lua
33
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
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user