Patch to add right-click player callback (0.4.15)

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

Patch to add right-click player callback (0.4.15)

by sorcerykid » Post

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: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

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

by Krock » Post

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

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

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

by zeuner » Post

It has been trivial to port to 5.0.0-dev (https://github.com/zeuner/minetest/comm ... b277a91edf), 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
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

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

by pandaro » Post

why not already PR? seem nice!

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

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

by Sokomine » Post

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.

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

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

by runs » Post

Please implement this. I would need for my new mod "Dialogue" :-(

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

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

by zeuner » Post

pandaro wrote:why not already PR? seem nice!
I think this would be up to the author sorcerykid. I wouldn't want to claim ownership of the code by opening a pull request from my account.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests