make loose node settling use an increasing ABM.

loose nodes will now take some time to settle, instead of doing so
completely randomly.
This commit is contained in:
trans_soup 2023-10-17 21:03:34 +02:00
parent 5df44d2b24
commit 07781855ad

View file

@ -1,18 +1,28 @@
local function attempt_settle_at (pos) local modname = minetest.get_current_modname()
local below = pos + blockgame.vector.dirs.down
if minetest.get_node(below).name == "air" then return end
local def = minetest.registered_nodes[minetest.get_node(pos).name] -- settle nodes that have been still for a while.
minetest.set_node(pos, {name = def.settle_into}) blockgame.register_increasing_abm({
end id = modname .. ":settle_loose_nodes",
-- settle nodes that are still (in the future, it will take some time for loose nodes that are still to settle).
blockgame.register_abm({
label = "settle loose nodes", label = "settle loose nodes",
nodenames = {"group:loose"}, nodenames = {"group:loose"},
interval = 30, interval = 20,
chance = 10, chance = 5,
action = attempt_settle_at, rate = function (pos, node, data)
return data.value + math.random(1, 9)
end,
check = function (pos, node, data)
local below = pos + blockgame.vector.dirs.down
if minetest.get_node(below).name == "air" then
minetest.check_for_falling(pos)
return false
end
return data.value >= 30
end,
action = function (pos, node, data)
local def = minetest.registered_nodes[node.name]
minetest.set_node(pos, {name = def.settle_into})
end,
}) })