30 lines
755 B
Lua
30 lines
755 B
Lua
|
-- TODO: collapse nodes when the node under them is removed.
|
||
|
|
||
|
local function attempt_collapse_at (pos, node)
|
||
|
node = node or minetest.get_node(pos)
|
||
|
|
||
|
local below = pos + blockgame.vector.dirs.down
|
||
|
if minetest.get_node(below).name ~= "air" then return end
|
||
|
|
||
|
local node_def = minetest.registered_nodes[node.name]
|
||
|
if type(node_def.fall_check) == "function" then
|
||
|
if not node_def.fall_check(pos, node) then return end
|
||
|
end
|
||
|
|
||
|
minetest.spawn_falling_node(pos)
|
||
|
end
|
||
|
|
||
|
-- collapse nodes that somehow managed to stay in the air.
|
||
|
blockgame.register_abm({
|
||
|
label = "collapse falling nodes",
|
||
|
nodenames = {"group:can_fall"},
|
||
|
neighbors = {"air"},
|
||
|
interval = 15,
|
||
|
chance = 1,
|
||
|
action = attempt_collapse_at,
|
||
|
})
|
||
|
|
||
|
return {
|
||
|
attempt_collapse_at = attempt_collapse_at,
|
||
|
}
|