local modname = minetest.get_current_modname() -- 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 = 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, }) local events = blockgame.events.namespace("api") events.listen("before_register_node", function (data) local name = data.name local def = data.def local mod = data.mod if not def.loose_variant then return end blockgame.register_node(def.loose_variant, { description = "Loose " .. def.description, tiles = def.tiles, -- temporary groups = blockgame.underride({ loose = 1, falling_node = 1 }, def.groups), settle_into = mod .. ":" .. name, }, mod) end)