blockgame/mods/bg_tree/grow_root.lua

24 lines
557 B
Lua
Raw Normal View History

local modname = minetest.get_current_modname()
local root_alive = modname .. ":root_alive"
blockgame.register_abm({
label = "kill roots",
nodenames = {root_alive},
interval = 20,
chance = 1,
action = function (pos, node)
local can_live = blockgame.any(blockgame.vector.get_neighbors(pos), function (pos)
return blockgame.item_matches(minetest.get_node(pos).name, {
root_alive,
modname .. ":log_alive",
modname .. ":sapling",
})
end)
if can_live then return end
minetest.set_node(pos, {name = modname .. ":root"})
end,
})