Patch to add right-click player callback (0.4.15)

For people working on the C++ code.
User avatar
sorcerykid
Member
 
Posts: 852
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
Krock
Developer
 
Posts: 4114
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>
 

zeuner
Member
 
Posts: 23
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 (https://github.com/zeuner/minetest/commit/f24043495db0d2250b9891b3d4a0efb277a91edf), 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.
 


Return to Partly official engine development



Who is online

Users browsing this forum: srifqi and 0 guests