From 1d3751d7552a3db54b2e9745840bf5ca119db08e Mon Sep 17 00:00:00 2001 From: Jordan Leppert Date: Mon, 6 Dec 2021 09:42:33 +0000 Subject: [PATCH] Avoid one node vines on top of trees. --- vines/init.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vines/init.lua b/vines/init.lua index 9f7aeac..9e435a1 100644 --- a/vines/init.lua +++ b/vines/init.lua @@ -83,12 +83,14 @@ vines.register_vine = function( name, defs, biome ) local spawn_plants = function(pos, fdir) local max_length = math.random(defs.average_length) local current_length = 1 - 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 }) - pos.y = pos.y - 1 - current_length = 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 + minetest.swap_node(pos, { name = vine_name_middle, param2 = fdir }) + pos.y = pos.y - 1 + current_length = current_length + 1 + end + minetest.set_node(pos, { name = vine_name_end, param2 = fdir }) end - minetest.set_node(pos, { name = vine_name_end, param2 = fdir }) end local vine_group = 'group:' .. name .. '_vines'