local modname = minetest.get_current_modname() local api = blockgame.tree local vec = blockgame.vector -- NODE NAMES local leaves = modname .. ":leaves" local leaves_decomposing = modname .. ":leaves_decomposing" -- END OF NODE NAMES blockgame.register_increasing_abm({ id = "bg_tree:begin_decompose", label = "decompose leaves", nodenames = {leaves}, neighbors = {"group:dirty"}, interval = 15, chance = 4, rate = function (pos, node, data) return data.value + math.random(4, 6) end, check = function (pos, node, data) return data.value >= 20 end, action = function (pos, node, data) minetest.set_node(pos, {name = leaves_decomposing}) end, }) blockgame.register_increasing_abm({ id = "bg_tree:decompose", label = "decompose leaves", nodenames = {leaves_decomposing}, neighbors = {"group:dirty"}, interval = 20, chance = 8, rate = function (pos, node, data) -- TODO: decompose faster depending on surrounding dirty nodes & other decomposing leaves. -- can probably do that with a flood fill that counts up a "score" depending on the nodes it encounters. return data.value + math.random(1, 9) end, check = function (pos, node, data) return data.value >= 25 end, action = function (pos, node, data) minetest.set_node(pos, {name = "bg_terrain:dirt"}) end, })