From 4bffabfa60bde63056d648aac69a72068bbe9021 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Fri, 7 Feb 2014 18:18:03 +0000 Subject: [PATCH 1/3] Show area names on hud --- hud.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hud.lua b/hud.lua index 19a3f35..40fe45e 100644 --- a/hud.lua +++ b/hud.lua @@ -19,7 +19,7 @@ minetest.register_globalstep(function(dtime) if area.open then ownertxt = ownertxt.."/open" end - areaString = areaString..id.." ("..ownertxt..")" + areaString = areaString..area.name.." ("..id.."/"..ownertxt..")" end if not areas.hud[name] then areas.hud[name] = {} From c523b44190c60a8acf34e51d598c79c447a60d6d Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Sat, 22 Mar 2014 10:38:45 +0000 Subject: [PATCH 2/3] Add api function to find nearest area --- api.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/api.lua b/api.lua index d6a2cfd..424f355 100644 --- a/api.lua +++ b/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 function areas:getAreasAtPos(pos) local a = {} From ec4de7833dfbd31bff74d97aea6ab2455d2d056a Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Sat, 22 Mar 2014 10:53:55 +0000 Subject: [PATCH 3/3] Fix various readme typos --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 24920b3..86792d2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Configuration ------------- If you wish to specify configuration options, such as whether players are 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 @@ -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. 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 -with the /add\_owner command. Anyone with a area can use the add\_owner +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 an area can use the add\_owner 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 -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 the markers at the corners of an existing area. The add\_owner command expects three arguments: @@ -46,16 +46,16 @@ For example: /add\_owner 123 BobTheBuilder Diamond lighthouse Chat commands ------------- * /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> - Protects a area. (Requires the "areas" privilege) + Protects an area. (Requires the "areas" privilege) * /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> - 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. * /list\_areas @@ -68,15 +68,15 @@ Chat commands /find_areas [Cc]astle To find castles. * /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 parent. * /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 the owner of a area. + Change the owner of an area. * /select\_area <ID> Sets the area positions to those of an existing area.