Patch to add right-click player callback (0.4.15)

For people working on the C++ code.
User avatar
Posts: 1061
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

Patch to add right-click player callback (0.4.15)

by sorcerykid » Mon Aug 27, 2018 04:14

Minetest does not (natively) support right-click events with player objects. So I implemented the following callback for use on my server. It's an easy enough patch, so I figured I'd share it here since other users have asked for the code.

Patch for 'on_rightclickplayer' callback (Minetest 0.4.17)

This is an example of the new on_rightclickplayer callback in Lua:

Code: Select all
minetest.register_on_rightclickplayer( function( player, clicker )
        print( player:get_player_name( ), "clicked", clicker:get_player_name( ) )
end )

Note: Currently I've only made a patch for Minetest 0.4.17. Earlier versions will be forthcoming as well.

User avatar
Posts: 4364
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: Patch to add right-click player callback (0.4.15)

by Krock » Mon Aug 27, 2018 10:53

Nice. Would you mind opening a PR for this change to integrate it into 5.0.0-dev?
>> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

Posts: 25
Joined: Fri Dec 01, 2017 20:09
GitHub: zeuner

Re: Patch to add right-click player callback (0.4.15)

by zeuner » Tue Aug 28, 2018 10:33

It has been trivial to port to 5.0.0-dev (, and seems to work nicely on my test server.

@sorcerykid: Please feel free to upload the ported patch using your account if you decide to post a PR, so that you receive proper credit for your work.

User avatar
Posts: 320
Joined: Sun Jan 08, 2012 21:34
Location: behind
GitHub: pandaro

Posts: 3864
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: Patch to add right-click player callback (0.4.15)

by Sokomine » Sat Aug 10, 2019 13:42

Nice idea. Could be useful for exchanging items without having to throw them to the ground or place into a chest, could be used to provide information about a player (name, experience gained, mobs killed, deaths, areas protected, ..), provide an admin interface etc.

Hope this gets merged! I'm also eager to see HTML-like formspec elements getting merged. With that, chats with mobs like in old point&click adventures are possible.
A list of my mods can be found here.

Return to Partly official engine development

Who is online

Users browsing this forum: No registered users and 1 guest