From 1505290e24002ef7d7c330d24cea4c349f6c9f1f Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 8 Jan 2018 20:10:44 +0100 Subject: [PATCH] New way to attach node: attached_node_facedir --- GROUPS.md | 1 + mods/CORE/mcl_attached/description.txt | 1 + mods/CORE/mcl_attached/init.lua | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 mods/CORE/mcl_attached/description.txt create mode 100644 mods/CORE/mcl_attached/init.lua diff --git a/GROUPS.md b/GROUPS.md index c1b6f4eb5f..3116d64302 100644 --- a/GROUPS.md +++ b/GROUPS.md @@ -48,6 +48,7 @@ Please read to learn how digging times * `destroys_items=1`: If an item happens to be *inside* this node, the item will be destroyed * `no_eat_delay=1`: Only for foodstuffs. When eating this, all eating delays are ignored. * `can_eat_when_full=1`: Only for foodstuffs. This item can be eaten when the user has a full hunger bar +* `attached_node_facedir=1`: Like `attached_node`, but for facedir nodes #### Footnotes diff --git a/mods/CORE/mcl_attached/description.txt b/mods/CORE/mcl_attached/description.txt new file mode 100644 index 0000000000..3532db31db --- /dev/null +++ b/mods/CORE/mcl_attached/description.txt @@ -0,0 +1 @@ +Adds additional ways for nodes to be attached. diff --git a/mods/CORE/mcl_attached/init.lua b/mods/CORE/mcl_attached/init.lua new file mode 100644 index 0000000000..45e1e56b03 --- /dev/null +++ b/mods/CORE/mcl_attached/init.lua @@ -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 +