blockgame/mods/bg_api_fall/falling_node.lua
trans_soup 0c9f6a7119 move falling node code to own mod.
create `bg_api_fall` mod, and move files `falling_node.lua` and `loose_node.lua` to there from `bg_api`.

update dependencies in other mods to account for this change.
2023-10-17 18:54:23 +02:00

29 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,
}