mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2024-12-25 01:50:20 +01:00
improve air detection for tree and giant tree ferns
This commit is contained in:
parent
b7450d3ad1
commit
c43375ff7a
@ -61,32 +61,39 @@ 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
|
||||
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"})
|
||||
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"})
|
||||
|
||||
-- all the checking for air below is to prevent some ugly bugs (incomplete trunks of neighbouring trees), it's a bit slower, but worth the result
|
||||
-- all the checking for air below is to prevent some ugly bugs (incomplete trunks of neighbouring trees), it's a bit slower, but worth the result
|
||||
|
||||
-- assert(#leafchecks == 4)
|
||||
for i = 1, 4 do
|
||||
local positions = leafchecks[i].positions
|
||||
local rot = leafchecks[i].direction
|
||||
local endpos = 4 -- If the loop below adds all intermediate leaves then the "terminating" leaf will be at positions[4]
|
||||
-- assert(#positions == 4)
|
||||
-- add leaves so long as the destination nodes are air
|
||||
for j = 1, 3 do
|
||||
if minetest.get_node(positions[j]).name == "air" then
|
||||
minetest.set_node(positions[j], {name="ferns:tree_fern_leave_big"})
|
||||
else
|
||||
endpos = j
|
||||
break
|
||||
-- assert(#leafchecks == 4)
|
||||
for i = 1, 4 do
|
||||
local positions = leafchecks[i].positions
|
||||
local rot = leafchecks[i].direction
|
||||
local endpos = 4 -- If the loop below adds all intermediate leaves then the "terminating" leaf will be at positions[4]
|
||||
-- assert(#positions == 4)
|
||||
-- add leaves so long as the destination nodes are air
|
||||
for j = 1, 3 do
|
||||
if minetest.get_node(positions[j]).name == "air" then
|
||||
minetest.set_node(positions[j], {name="ferns:tree_fern_leave_big"})
|
||||
else
|
||||
endpos = j
|
||||
break
|
||||
end
|
||||
end
|
||||
-- add the terminating leaf if required and possible
|
||||
if endpos == 4 and minetest.get_node(positions[endpos]).name == "air" then
|
||||
minetest.set_node(positions[endpos], {name="ferns:tree_fern_leave_big_end", param2=rot})
|
||||
end
|
||||
end
|
||||
-- add the terminating leaf if required and possible
|
||||
if endpos == 4 and minetest.get_node(positions[endpos]).name == "air" then
|
||||
minetest.set_node(positions[endpos], {name="ferns:tree_fern_leave_big_end", param2=rot})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -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
|
||||
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user