improve air detection for tree and giant tree ferns

This commit is contained in:
Vanessa Ezekowitz 2017-03-14 21:23:33 -04:00
parent b7450d3ad1
commit c43375ff7a
2 changed files with 40 additions and 24 deletions

View File

@ -61,9 +61,15 @@ abstract_ferns.grow_giant_tree_fern = function(pos)
}
}
local brk = false
for i = 1, size-3 do
if minetest.get_node({x = pos.x, y = pos.y + i, z = pos.z}).name ~= "air" then
brk = true
break
end
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, {name="ferns:fern_trunk_big"})
end
if not brk then
minetest.set_node({x = pos.x, y = pos.y + size-2, z = pos.z}, {name="ferns:fern_trunk_big_top"})
minetest.set_node({x = pos.x, y = pos.y + size-1, z = pos.z}, {name="ferns:tree_fern_leaves_giant"})
@ -89,6 +95,7 @@ abstract_ferns.grow_giant_tree_fern = function(pos)
minetest.set_node(positions[endpos], {name="ferns:tree_fern_leave_big_end", param2=rot})
end
end
end
end
-----------------------------------------------------------------------------------------------

View File

@ -26,15 +26,24 @@ abstract_ferns.grow_tree_fern = function(pos)
local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[math.random(1, 2)]
local i = 1
while (i < size-1) do
if minetest.get_node({x = pos.x, y = pos.y + i + 1, z = pos.z}).name ~= "air" then
local brk = false
while (i < size) do
print(minetest.get_node({x = pos.x, y = pos.y + i, z = pos.z}).name)
if minetest.get_node({x = pos.x, y = pos.y + i, z = pos.z}).name ~= "air" then
brk = true
print("break!")
break
end
print("set trunk node at:")
print(dump({x = pos.x, y = pos.y + i, z = pos.z}))
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = "ferns:fern_trunk" })
i = i + 1
end
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = crown })
if not brk then
print("set crown node at:")
print(dump({x = pos.x, y = pos.y + i, z = pos.z}))
minetest.set_node({x = pos.x, y = pos.y + i - 1, z = pos.z}, { name = crown })
end
end
-----------------------------------------------------------------------------------------------