Fix to on_rightclick not able to change wielded_item
authorRealBadAngel <mk@realbadangel.pl>
Tue, 12 Feb 2013 21:51:38 +0000 (22:51 +0100)
committerIlya Zhuravlev <zhuravlevilya@ya.ru>
Tue, 12 Feb 2013 22:06:36 +0000 (02:06 +0400)
builtin/item.lua
doc/lua_api.txt

index a28798d4d3a21be5f5736dede4d875fd3cd72b81..acbdaa5338771e59233daab831beef192c2ce856 100644 (file)
@@ -237,8 +237,7 @@ function minetest.item_place(itemstack, placer, pointed_thing)
                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
+                       return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, n, placer, itemstack)
                end
        end
 
index 7ba2ed0011fa69249cb9fed6321faa1213542686..af70a1047672ffbb098ce4ac93f9a6a784f78818 100644 (file)
@@ -1497,8 +1497,10 @@ Node definition (register_node)
     on_punch = func(pos, node, puncher),
     ^ default: minetest.node_punch
     ^ By default: does nothing
-    on_rightclick = func(pos, node, clicker),
+    on_rightclick = func(pos, node, clicker, itemstack),
     ^ default: nil
+    ^ if defined, itemstack will hold clicker's wielded item
+      Shall return the leftover itemstack
     on_dig = func(pos, node, digger),
     ^ default: minetest.node_dig
     ^ By default: checks privileges, wears out tool and removes node