]> git.lizzy.rs Git - minetest.git/commitdiff
Trigger on_rightclick regardless on the formspec meta field
authorSmallJoker <mk939@ymail.com>
Thu, 10 Aug 2017 07:41:56 +0000 (09:41 +0200)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:31:59 +0000 (17:31 +0200)
Document behaviour for older clients.

doc/lua_api.txt
src/game.cpp

index aefcba064920773f5f6daa000f21d7df0853cac6..edef755938c9df1f04ce239796aa24cae2d10a32 100644 (file)
@@ -4261,9 +4261,11 @@ Definition tables
         ^ By default: Calls minetest.register_on_punchnode callbacks ]]
         on_rightclick = func(pos, node, clicker, itemstack, pointed_thing), --[[
         ^ default: nil
-        ^ if defined, itemstack will hold clicker's wielded item
+        ^ itemstack will hold clicker's wielded item
         ^ Shall return the leftover itemstack
-        ^ Note: pointed_thing can be nil, if a mod calls this function ]]
+        ^ Note: pointed_thing can be nil, if a mod calls this function
+          This function does not get triggered by clients <=0.4.16 if the
+          "formspec" node metadata field is set ]]
 
         on_dig = func(pos, node, digger), --[[
         ^ default: minetest.node_dig
index 8958826ad879f29b02dfd4e8cbcc3c46941b87b1..68acc81b7400dbcf2586c009c9781f0b35748240 100644 (file)
@@ -3801,6 +3801,11 @@ void Game::handlePointingAtNode(const PointedThing &pointed,
 
                if (meta && meta->getString("formspec") != "" && !random_input
                                && !isKeyDown(KeyType::SNEAK)) {
+                       // Report right click to server
+                       if (nodedef_manager->get(map.getNodeNoEx(nodepos)).rightclickable) {
+                               client->interact(3, pointed);
+                       }
+
                        infostream << "Launching custom inventory view" << std::endl;
 
                        InventoryLocation inventoryloc;