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.
This commit is contained in:
Auke Kok 2016-10-12 10:21:44 -07:00
parent 3161129a93
commit e4c57c2841

View File

@ -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