diff options
author | kwolekr <kwolekr@minetest.net> | 2013-06-28 22:52:13 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2013-06-28 22:52:13 -0400 |
commit | 0003fc8215a9741af850e6dc631ed3849c576125 (patch) | |
tree | e13624369bc9300c233b446ad5110c2b54b0f4b3 /builtin | |
parent | 9126823c7e3f16d5a7bc03a30ebbbff66378f6e9 (diff) | |
download | minetest-0003fc8215a9741af850e6dc631ed3849c576125.tar.gz minetest-0003fc8215a9741af850e6dc631ed3849c576125.tar.bz2 minetest-0003fc8215a9741af850e6dc631ed3849c576125.zip |
Add Lua VoxelArea methods: contains, containsp, containsi
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/voxelarea.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/builtin/voxelarea.lua b/builtin/voxelarea.lua index 9426c3acf..dd9af7910 100644 --- a/builtin/voxelarea.lua +++ b/builtin/voxelarea.lua @@ -44,3 +44,19 @@ function VoxelArea:indexp(p) return math.floor(i) end +function VoxelArea:contains(x, y, z) + return (x >= self.MinEdge.x) and (x <= self.MaxEdge.x) and + (y >= self.MinEdge.y) and (y <= self.MaxEdge.y) and + (z >= self.MinEdge.z) and (z <= self.MaxEdge.z) +end + +function VoxelArea:containsp(p) + return (p.x >= self.MinEdge.x) and (p.x <= self.MaxEdge.x) and + (p.y >= self.MinEdge.y) and (p.y <= self.MaxEdge.y) and + (p.z >= self.MinEdge.z) and (p.z <= self.MaxEdge.z) +end + +function VoxelArea:containsi(i) + return (i >= 1) and (i <= self:getVolume()) +end + |