diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-07 18:28:37 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-07 18:28:37 +0200 |
commit | 9790a6817cb4f1b4821de9af2630558cb5df882f (patch) | |
tree | ed9fd86bef0a74f0fcdc9b9bed12bb49c274b146 /MCServer/Plugins/ProtectionAreas/PlayerAreas.lua | |
parent | ProtectionAreas: Newly added areas are stored in the DB (diff) | |
download | cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.gz cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.bz2 cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.lz cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.xz cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.tar.zst cuberite-9790a6817cb4f1b4821de9af2630558cb5df882f.zip |
Diffstat (limited to '')
-rw-r--r-- | MCServer/Plugins/ProtectionAreas/PlayerAreas.lua | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/MCServer/Plugins/ProtectionAreas/PlayerAreas.lua b/MCServer/Plugins/ProtectionAreas/PlayerAreas.lua index 5d054ea15..e77d4699f 100644 --- a/MCServer/Plugins/ProtectionAreas/PlayerAreas.lua +++ b/MCServer/Plugins/ProtectionAreas/PlayerAreas.lua @@ -37,7 +37,7 @@ end -- Adds a new cuboid to the area list, where the player is either allowed or not, depending on the IsAllowed param
function cPlayerAreas:AddArea(a_Cuboid, a_IsAllowed)
- table.insert(self, {Cuboid = a_Cuboid, IsAllowed = a_IsAllowed});
+ table.insert(self, {m_Cuboid = a_Cuboid, m_IsAllowed = a_IsAllowed});
end
@@ -45,12 +45,12 @@ end --- returns true if the player owning this object can interact with the specified block
-function cPlayerAreas:CanInteractWithBlock(a_BlockX, a_BlockY, a_BlockZ)
+function cPlayerAreas:CanInteractWithBlock(a_BlockX, a_BlockZ)
-- iterate through all the stored areas:
local IsInsideAnyArea = false;
for idx, Area in ipairs(self) do
- if (Area.Cuboid:IsInside(a_BlockX, a_BlockY, a_BlockZ)) then
- if (Area.IsAllowed) then
+ if (Area.m_Cuboid:IsInside(a_BlockX, 1, a_BlockZ)) then -- We don't care about Y coords, so use a dummy value
+ if (Area.m_IsAllowed) then
return true;
end
-- The coords are inside a cuboid for which the player doesn't have access, take a note of it
@@ -71,3 +71,19 @@ end +
+--- Calls the specified callback for each area contained within
+-- a_Callback has a signature: function(a_Cuboid, a_IsAllowed)
+-- Returns true if all areas have been enumerated, false if the callback has aborted by returning true
+function cPlayerAreas:ForEachArea(a_Callback)
+ for idx, Area in ipairs(self) do
+ if (a_Callback(Area.m_Cuboid, Area.m_IsAllowed)) then
+ return false;
+ end
+ end
+ return true;
+end
+
+
+
+
|