update decomposition to use increasing ABM:s.

This commit is contained in:
trans_soup 2023-10-16 21:30:57 +02:00
parent 453add021d
commit dcb0eb257e
1 changed files with 22 additions and 8 deletions

View File

@ -9,26 +9,40 @@ local leaves_decomposing = modname .. ":leaves_decomposing"
-- END OF NODE NAMES
-- TODO: replace these with over-time thing when that's added.
blockgame.register_abm({
blockgame.register_increasing_abm({
id = "bg_tree:begin_decompose",
label = "decompose leaves",
nodenames = {leaves},
neighbors = {"group:dirty"},
interval = 15,
chance = 4,
action = function (pos, node)
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_abm({
blockgame.register_increasing_abm({
id = "bg_tree:decompose",
label = "decompose leaves",
nodenames = {leaves_decomposing},
neighbors = {"group:dirty"},
interval = 15,
chance = 4,
action = function (pos, node)
interval = 30,
chance = 10,
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 >= 30
end,
action = function (pos, node, data)
minetest.set_node(pos, {name = "bg_terrain:dirt"})
end,
})