aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorPilzAdam <PilzAdam@gmx.de>2013-01-04 00:05:56 +0100
committerPilzAdam <PilzAdam@gmx.de>2013-01-04 17:15:16 +0100
commit5bc14e2fe45f12cdb69d302807d05985ee5552ee (patch)
tree13a95b1597ea24752fb267bf17abb4ff556dc142 /builtin
parentd2b1210376f6cc52fe031ac41d3bf54720ebd356 (diff)
downloadminetest-5bc14e2fe45f12cdb69d302807d05985ee5552ee.tar.gz
minetest-5bc14e2fe45f12cdb69d302807d05985ee5552ee.tar.bz2
minetest-5bc14e2fe45f12cdb69d302807d05985ee5552ee.zip
Add on_rightclick(pos, node, clicker) callback for nodes
Diffstat (limited to 'builtin')
-rw-r--r--builtin/item.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/builtin/item.lua b/builtin/item.lua
index acc1e6262..d36e8a758 100644
--- a/builtin/item.lua
+++ b/builtin/item.lua
@@ -231,9 +231,19 @@ function minetest.item_place_object(itemstack, placer, pointed_thing)
end
function minetest.item_place(itemstack, placer, pointed_thing)
+ -- Call on_rightclick if the pointed node defines it
+ if pointed_thing.type == "node" then
+ local n = minetest.env:get_node(pointed_thing.under)
+ local nn = n.name
+ if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then
+ minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, n, placer)
+ return
+ end
+ end
+
if itemstack:get_definition().type == "node" then
return minetest.item_place_node(itemstack, placer, pointed_thing)
- else
+ elseif itemstack:get_definition().type ~= "none" then
return minetest.item_place_object(itemstack, placer, pointed_thing)
end
end
@@ -375,6 +385,7 @@ minetest.nodedef_default = {
can_dig = nil,
on_punch = redef_wrapper(minetest, 'node_punch'), -- minetest.node_punch
+ on_rightclick = nil,
on_dig = redef_wrapper(minetest, 'node_dig'), -- minetest.node_dig
on_receive_fields = nil,
@@ -464,7 +475,7 @@ minetest.noneitemdef_default = { -- This is used for the hand and unknown items
tool_capabilities = nil,
-- Interaction callbacks
- on_place = nil,
+ on_place = redef_wrapper(minetest, 'item_place'),
on_drop = nil,
on_use = nil,
}