From 2fee75166fa3515bac52b9550eb8e60678c4ab73 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Tue, 24 Feb 2015 00:14:37 -0800 Subject: Fix topmost block detection. 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. --- init.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index c2eddbc..b008318 100644 --- a/init.lua +++ b/init.lua @@ -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 -- cgit v1.2.3