forked from mtcontrib/plantlife_modpack
Prevent two separate instances of stack overflow.
The first one happens because `remove_node` is called directly, calling `remove_node` for the vine below, calling `remove_node` for the vine below, calling... The second one happens because `get_item_group` returns 0 for groups not set, and 0 is a truthy value in Lua, so the code always removes the bottom node regardless of its group rating. This interacted funnily with doors wanting to remove their top node, while vines wanted to remove their bottom nodes.
This commit is contained in:
parent
e801716f57
commit
d85fb4c64f
@ -82,8 +82,10 @@ vines.register_vine = function( name, defs, biome )
|
|||||||
local node = minetest.get_node( pos )
|
local node = minetest.get_node( pos )
|
||||||
local bottom = {x=pos.x, y=pos.y-1, z=pos.z}
|
local bottom = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
local bottom_node = minetest.get_node( bottom )
|
local bottom_node = minetest.get_node( bottom )
|
||||||
if minetest.get_item_group( bottom_node.name, "vines") then
|
if minetest.get_item_group( bottom_node.name, "vines") > 0 then
|
||||||
minetest.remove_node( bottom )
|
-- Calling `remove_node` directly would cause
|
||||||
|
-- a stack overflow for really long vines.
|
||||||
|
minetest.after( 0, minetest.remove_node, bottom )
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
after_dig_node = function( pos, node, oldmetadata, user )
|
after_dig_node = function( pos, node, oldmetadata, user )
|
||||||
|
Loading…
Reference in New Issue
Block a user