diff options
author | Auke Kok <auke-jan.h.kok@intel.com> | 2015-02-24 00:14:37 -0800 |
---|---|---|
committer | Auke Kok <auke-jan.h.kok@intel.com> | 2015-02-24 00:14:37 -0800 |
commit | 2fee75166fa3515bac52b9550eb8e60678c4ab73 (patch) | |
tree | 6cdbe280b063478ee9ffbd18e4317a5799b8e1d2 | |
parent | 19f3c53f053f34664a0a3ac463d1c980510a0455 (diff) |
Fix topmost block detection.v2
Without this we'll be eroding blocks under canopies and roofs, even
in caves. This code really assures that we're looking at the world-
topmost non-air block.
-rw-r--r-- | init.lua | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -91,6 +91,10 @@ local function pos_is_node(pos) return minetest.get_node_or_nil(pos) end +local function pos_is_ignore(pos) + return minetest.get_node(pos).name == "ignore" +end + local function node_is_air(node) return node.name == "air" end @@ -270,14 +274,12 @@ local function sed() {x = pos.x + 3, y = pos.y + 100, z = pos.z + 3} ) - -- now go find the topmost non-air block + -- now go find the topmost world block repeat pos = pos_above(pos) - if not minetest.get_node_or_nil(pos) then - return - end - until node_is_air(minetest.get_node(pos)) + until pos_is_ignore(pos) + -- then find lowest air block repeat pos = pos_below(pos) if not minetest.get_node_or_nil(pos) then |