New way to attach node: attached_node_facedir

This commit is contained in:
Wuzzy 2018-01-08 20:10:44 +01:00
parent dfc0d52372
commit 1505290e24
3 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1 @@
Adds additional ways for nodes to be attached.

View file

@ -0,0 +1,24 @@
local original_function = minetest.check_single_for_falling
minetest.check_single_for_falling = function(pos)
local ret_o = original_function(pos)
local ret = false
local node = minetest.get_node(pos)
if minetest.get_item_group(node.name, "attached_node_facedir") ~= 0 then
local dir = minetest.facedir_to_dir(node.param2)
local cpos = vector.add(pos, dir)
local cnode = minetest.get_node(cpos)
if minetest.get_item_group(cnode.name, "solid") == 0 then
minetest.remove_node(pos)
local drops = minetest.get_node_drops(node.name, "")
for dr=1, #drops do
minetest.add_item(pos, drops[dr])
end
ret = true
end
end
return ret_o or ret
end