blockgame/mods/bg_tree/grow_root.lua
trans_soup dd796c549e make unsupported roots die.
make `root_alive` nodes turn into `root` nodes if they're not touching
any of these nodes: `root_alive`, `log_alive`, `sapling`.
2023-10-19 14:53:15 +02:00

23 lines
557 B
Lua

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,
})