From e4c57c28414de13bfd36970e6f1d0df223ce57f1 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 12 Oct 2016 10:21:44 -0700 Subject: [PATCH] Allow torches to be placed in itemframes. Pass the normal torch in on_rightclick() and never the wall torch. This makes xdecor:itemframe display the right item, as well as drop the right item. --- init.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 2e52648..7761c74 100644 --- a/init.lua +++ b/init.lua @@ -28,11 +28,23 @@ minetest.register_node(":default:torch", { }, sounds = default.node_sound_wood_defaults(), on_place = function(itemstack, placer, pointed_thing) - local above = pointed_thing.above + if pointed_thing.type ~= "node" then + -- no interaction possible with entities, for now. + return itemstack + end + local under = pointed_thing.under + local node = minetest.get_node(under) + local def = minetest.registered_nodes[node.name] + if def and def.on_rightclick then + return def.on_rightclick(under, node, placer, itemstack, + pointed_thing) or itemstack, false + end + + local above = pointed_thing.above local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}) local fakestack = itemstack - local retval = false + local retval if wdir <= 1 then retval = fakestack:set_name("default:torch") else @@ -41,7 +53,8 @@ minetest.register_node(":default:torch", { if not retval then return itemstack end - itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir) + + itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir) itemstack:set_name("default:torch") return itemstack