From 4d02af8c940061ace594950c353ab014751a7c81 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Thu, 13 Jan 2022 07:17:24 +0100 Subject: [PATCH] Convert correct floor node to dirt as gourd grows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this patch, growing a gourd (e.g. melon, pumpkin) would always convert a node west of the node below the stem to dirt if belonged to the group “dirtifies_below_solid”. This happened because of a loop in which the variables floorpos and floor were re-used without setting a new value … therefore, both floorpos and floor were always containing the last values set in a previous loop instead of the correct values. This patch fixes the problem by setting both variables in both loops. --- mods/ITEMS/mcl_farming/shared_functions.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_farming/shared_functions.lua b/mods/ITEMS/mcl_farming/shared_functions.lua index 90f7d337..6be9e527 100644 --- a/mods/ITEMS/mcl_farming/shared_functions.lua +++ b/mods/ITEMS/mcl_farming/shared_functions.lua @@ -388,12 +388,11 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s { x=0, y=0, z=-1 }, { x=0, y=0, z=1 }, } - local floorpos, floor for n=#neighbors, 1, -1 do local offset = neighbors[n] local blockpos = vector.add(stempos, offset) - floorpos = { x=blockpos.x, y=blockpos.y-1, z=blockpos.z } - floor = minetest.get_node(floorpos) + local floorpos = { x=blockpos.x, y=blockpos.y-1, z=blockpos.z } + local floor = minetest.get_node(floorpos) local block = minetest.get_node(blockpos) local soilgroup = minetest.get_item_group(floor.name, "soil") if not ((minetest.get_item_group(floor.name, "grass_block") == 1 or floor.name=="mcl_core:dirt" or soilgroup == 2 or soilgroup == 3) and block.name == "air") then @@ -407,6 +406,8 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s local r = math.random(1, #neighbors) local offset = neighbors[r] local blockpos = vector.add(stempos, offset) + local floorpos = { x=blockpos.x, y=blockpos.y-1, z=blockpos.z } + local floor = minetest.get_node(floorpos) local p2 if offset.x == 1 then minetest.set_node(stempos, {name=connected_stem_names[1]})