mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2024-12-25 18:10:19 +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
|
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"})
|
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, {name="ferns:fern_trunk_big"})
|
||||||
end
|
end
|
||||||
minetest.set_node({x = pos.x, y = pos.y + size-2, z = pos.z}, {name="ferns:fern_trunk_big_top"})
|
if not brk then
|
||||||
minetest.set_node({x = pos.x, y = pos.y + size-1, z = pos.z}, {name="ferns:tree_fern_leaves_giant"})
|
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)
|
-- assert(#leafchecks == 4)
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
local positions = leafchecks[i].positions
|
local positions = leafchecks[i].positions
|
||||||
local rot = leafchecks[i].direction
|
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]
|
local endpos = 4 -- If the loop below adds all intermediate leaves then the "terminating" leaf will be at positions[4]
|
||||||
-- assert(#positions == 4)
|
-- assert(#positions == 4)
|
||||||
-- add leaves so long as the destination nodes are air
|
-- add leaves so long as the destination nodes are air
|
||||||
for j = 1, 3 do
|
for j = 1, 3 do
|
||||||
if minetest.get_node(positions[j]).name == "air" then
|
if minetest.get_node(positions[j]).name == "air" then
|
||||||
minetest.set_node(positions[j], {name="ferns:tree_fern_leave_big"})
|
minetest.set_node(positions[j], {name="ferns:tree_fern_leave_big"})
|
||||||
else
|
else
|
||||||
endpos = j
|
endpos = j
|
||||||
break
|
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
|
||||||
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
|
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 crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[math.random(1, 2)]
|
||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
while (i < size-1) do
|
local brk = false
|
||||||
if minetest.get_node({x = pos.x, y = pos.y + i + 1, z = pos.z}).name ~= "air" then
|
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
|
break
|
||||||
end
|
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" })
|
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = "ferns:fern_trunk" })
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
if not brk then
|
||||||
minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = crown })
|
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
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user