Skip to content

Commit

Permalink
Trigger on_rightclick regardless on the formspec meta field
Browse files Browse the repository at this point in the history
Document behaviour for older clients.
  • Loading branch information
SmallJoker authored and paramat committed Aug 13, 2017
1 parent fa7fe40 commit 4381fe0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions doc/lua_api.txt
Expand Up @@ -4317,9 +4317,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
Expand Down
5 changes: 5 additions & 0 deletions src/game.cpp
Expand Up @@ -3799,6 +3799,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;
Expand Down

0 comments on commit 4381fe0

Please sign in to comment.