Merge ec4de7833d
into ce8891a325
This commit is contained in:
commit
4473d1f44a
22
README.md
22
README.md
|
@ -7,7 +7,7 @@ Configuration
|
||||||
-------------
|
-------------
|
||||||
If you wish to specify configuration options, such as whether players are
|
If you wish to specify configuration options, such as whether players are
|
||||||
allowed to protect their own areas with /protect (Disabled by default), you
|
allowed to protect their own areas with /protect (Disabled by default), you
|
||||||
should check config.lua and set the apropriate settings in your minetest.conf.
|
should check config.lua and set the appropriate settings in your minetest.conf.
|
||||||
|
|
||||||
|
|
||||||
Tutorial
|
Tutorial
|
||||||
|
@ -29,11 +29,11 @@ The area name is used so that you can easily find the area that you want when
|
||||||
using a command like /list\_areas. It is not used for any other purpose.
|
using a command like /list\_areas. It is not used for any other purpose.
|
||||||
For example: /set\_owner SomePlayer Diamond city
|
For example: /set\_owner SomePlayer Diamond city
|
||||||
|
|
||||||
Now that you own a area you may want to add sub-owners to it. You can do this
|
Now that you own an area you may want to add sub-owners to it. You can do this
|
||||||
with the /add\_owner command. Anyone with a area can use the add\_owner
|
with the /add\_owner command. Anyone with an area can use the add\_owner
|
||||||
command on their areas. Before using the add\_owner command you have to select
|
command on their areas. Before using the add\_owner command you have to select
|
||||||
the corners of the sub-area as you did for set\_owner. If your markers are
|
the corners of the sub-area as you did for set\_owner. If your markers are
|
||||||
still around your origional area and you want to grant access to your entire
|
still around your original area and you want to grant access to your entire
|
||||||
area you will not have to re-set them. You can also use select\_area to place
|
area you will not have to re-set them. You can also use select\_area to place
|
||||||
the markers at the corners of an existing area.
|
the markers at the corners of an existing area.
|
||||||
The add\_owner command expects three arguments:
|
The add\_owner command expects three arguments:
|
||||||
|
@ -46,16 +46,16 @@ For example: /add\_owner 123 BobTheBuilder Diamond lighthouse
|
||||||
Chat commands
|
Chat commands
|
||||||
-------------
|
-------------
|
||||||
* /protect <AreaName>
|
* /protect <AreaName>
|
||||||
Protects a area for yourself. (If self-protection is enabled)
|
Protects an area for yourself. (If self-protection is enabled)
|
||||||
|
|
||||||
* /set\_owner <OwnerName> <AreaName>
|
* /set\_owner <OwnerName> <AreaName>
|
||||||
Protects a area. (Requires the "areas" privilege)
|
Protects an area. (Requires the "areas" privilege)
|
||||||
|
|
||||||
* /add\_owner <ParentID> <OwnerName> <ChildName>
|
* /add\_owner <ParentID> <OwnerName> <ChildName>
|
||||||
Grants annother player control over part(or all) of a area.
|
Grants another player control over part (or all) of an area.
|
||||||
|
|
||||||
* /rename\_area <ID> <NewName>
|
* /rename\_area <ID> <NewName>
|
||||||
Renames a existing area, usefull after converting from node_ownership
|
Renames an existing area, useful after converting from node_ownership
|
||||||
when all areas are unnamed.
|
when all areas are unnamed.
|
||||||
|
|
||||||
* /list\_areas
|
* /list\_areas
|
||||||
|
@ -68,15 +68,15 @@ Chat commands
|
||||||
/find_areas [Cc]astle To find castles.
|
/find_areas [Cc]astle To find castles.
|
||||||
|
|
||||||
* /remove\_area <ID>
|
* /remove\_area <ID>
|
||||||
Removes a area that you own. Any sub-areas of that area are made sub-areas
|
Removes an area that you own. Any sub-areas of that area are made sub-areas
|
||||||
of the removed area's parent, if it exists. Otherwise they will have no
|
of the removed area's parent, if it exists. Otherwise they will have no
|
||||||
parent.
|
parent.
|
||||||
|
|
||||||
* /recursive\_remove\_areas <ID>
|
* /recursive\_remove\_areas <ID>
|
||||||
Removes a area and all sub-areas of it.
|
Removes an area and all sub-areas of it.
|
||||||
|
|
||||||
* /change\_owner <ID> <NewOwner>
|
* /change\_owner <ID> <NewOwner>
|
||||||
Change the owner of a area.
|
Change the owner of an area.
|
||||||
|
|
||||||
* /select\_area <ID>
|
* /select\_area <ID>
|
||||||
Sets the area positions to those of an existing area.
|
Sets the area positions to those of an existing area.
|
||||||
|
|
42
api.lua
42
api.lua
|
@ -1,4 +1,46 @@
|
||||||
|
|
||||||
|
-- Temporary compatibility function - see minetest PR#1180
|
||||||
|
if not vector.interpolate then
|
||||||
|
vector.interpolate = function(pos1, pos2)
|
||||||
|
return {x = pos1.x + (pos2.x - pos1.x) * factor,
|
||||||
|
y = pos1.y + (pos2.y - pos1.y) * factor,
|
||||||
|
z = pos1.z + (pos2.z - pos1.z) * factor}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Returns the nearest area to the given position, optionally checking only
|
||||||
|
-- areas matching a given pattern (which is a lua regex). The pattern will
|
||||||
|
-- be amended to make it case-insensitive.
|
||||||
|
-- Returns nil if nothing could be found, otherwise the area and the
|
||||||
|
-- distance to it.
|
||||||
|
-- maxdist is the maximum distance at which to search.
|
||||||
|
function areas:findNearestArea(pos, pattern, maxdist)
|
||||||
|
|
||||||
|
local nearest, nearestdist
|
||||||
|
if pattern then
|
||||||
|
-- Make the pattern case-insensitive...
|
||||||
|
pattern = pattern:gsub("(%%?)(.)", function(percent, letter)
|
||||||
|
if percent ~= "" or not letter:match("%a") then
|
||||||
|
return percent .. letter
|
||||||
|
else
|
||||||
|
return string.format("[%s%s]", letter:lower(), letter:upper())
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
for id, area in pairs(self.areas) do
|
||||||
|
if (not pattern) or string.find(area.name, pattern) then
|
||||||
|
local centre = vector.interpolate(area.pos1, area.pos2, 0.5)
|
||||||
|
local dist = vector.distance(pos, centre)
|
||||||
|
if ((not nearestdist) or dist < nearestdist) and ((not maxdist) or dist <= maxdist) then
|
||||||
|
nearest = area
|
||||||
|
nearestdist = dist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nearest, nearestdist
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns a list of areas that include the provided position
|
-- Returns a list of areas that include the provided position
|
||||||
function areas:getAreasAtPos(pos)
|
function areas:getAreasAtPos(pos)
|
||||||
local a = {}
|
local a = {}
|
||||||
|
|
2
hud.lua
2
hud.lua
|
@ -19,7 +19,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
if area.open then
|
if area.open then
|
||||||
ownertxt = ownertxt.."/open"
|
ownertxt = ownertxt.."/open"
|
||||||
end
|
end
|
||||||
areaString = areaString..id.." ("..ownertxt..")"
|
areaString = areaString..area.name.." ("..id.."/"..ownertxt..")"
|
||||||
end
|
end
|
||||||
if not areas.hud[name] then
|
if not areas.hud[name] then
|
||||||
areas.hud[name] = {}
|
areas.hud[name] = {}
|
||||||
|
|
Loading…
Reference in New Issue