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:
parent
5df44d2b24
commit
07781855ad
1 changed files with 22 additions and 12 deletions
|
@ -1,18 +1,28 @@
|
|||
local function attempt_settle_at (pos)
|
||||
local below = pos + blockgame.vector.dirs.down
|
||||
if minetest.get_node(below).name == "air" then return end
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
minetest.set_node(pos, {name = def.settle_into})
|
||||
end
|
||||
|
||||
-- settle nodes that are still (in the future, it will take some time for loose nodes that are still to settle).
|
||||
blockgame.register_abm({
|
||||
-- settle nodes that have been still for a while.
|
||||
blockgame.register_increasing_abm({
|
||||
id = modname .. ":settle_loose_nodes",
|
||||
label = "settle loose nodes",
|
||||
nodenames = {"group:loose"},
|
||||
interval = 30,
|
||||
chance = 10,
|
||||
action = attempt_settle_at,
|
||||
interval = 20,
|
||||
chance = 5,
|
||||
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,
|
||||
})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue