Avoid one node vines on top of trees.

This commit is contained in:
Jordan Leppert 2021-12-06 09:42:33 +00:00
parent e2486ca7f5
commit 1d3751d755

View File

@ -83,6 +83,7 @@ vines.register_vine = function( name, defs, biome )
local spawn_plants = function(pos, fdir) local spawn_plants = function(pos, fdir)
local max_length = math.random(defs.average_length) local max_length = math.random(defs.average_length)
local current_length = 1 local current_length = 1
if minetest.get_node({ x=pos.x, y=pos.y - 1, z=pos.z }).name == 'air' then
while minetest.get_node({ x=pos.x, y=pos.y - 1, z=pos.z }).name == 'air' and current_length < max_length do while minetest.get_node({ x=pos.x, y=pos.y - 1, z=pos.z }).name == 'air' and current_length < max_length do
minetest.swap_node(pos, { name = vine_name_middle, param2 = fdir }) minetest.swap_node(pos, { name = vine_name_middle, param2 = fdir })
pos.y = pos.y - 1 pos.y = pos.y - 1
@ -90,6 +91,7 @@ vines.register_vine = function( name, defs, biome )
end end
minetest.set_node(pos, { name = vine_name_end, param2 = fdir }) minetest.set_node(pos, { name = vine_name_end, param2 = fdir })
end end
end
local vine_group = 'group:' .. name .. '_vines' local vine_group = 'group:' .. name .. '_vines'