rightclick player menu?

Post Reply
User avatar
theFox
Member
Posts: 192
Joined: Sun Feb 12, 2017 14:08
GitHub: theFox6
In-game: theFox
Location: Germany

rightclick player menu?

by theFox » Post

How about a menu that pops up when you rightclick a player?

featuring:
  • whisper
  • give items
  • (admin) kick
  • (admin) peek/open inventory
my mods and subgames (ง'̀-'́)ง

User avatar
PolySaken
Member
Posts: 696
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: rightclick player menu?

by PolySaken » Post

This would be quite easy to implement with a server side mod. Redefine hand on_secondary_use to check if pointed_thing is a player. Then open a formspec with said options.

User avatar
theFox
Member
Posts: 192
Joined: Sun Feb 12, 2017 14:08
GitHub: theFox6
In-game: theFox
Location: Germany

Re: rightclick player menu?

by theFox » Post

PolySaken wrote:This would be quite easy to implement with a server side mod.
I wanted to ask if anyone would appreciate this...
my mods and subgames (ง'̀-'́)ง

User avatar
PolySaken
Member
Posts: 696
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: rightclick player menu?

by PolySaken » Post

theFox wrote:I wanted to ask if anyone would appreciate this...
It would be a good idea for servers with no exchange/shop mods and for administrating players directly,
so I think some would.

User avatar
MineYoshi
Member
Posts: 5373
Joined: Wed Jul 08, 2015 13:20
Contact:

Re: rightclick player menu?

by MineYoshi » Post

theFox wrote:I wanted to ask if anyone would appreciate this...
It would make the game a lot easier, specially the part of giving items.
Oi

User avatar
PolySaken
Member
Posts: 696
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: rightclick player menu?

by PolySaken » Post

MineYoshi wrote:
theFox wrote:I wanted to ask if anyone would appreciate this...
It would make the game a lot easier, specially the part of giving items.
Maybe the talk option could be used to add realism? a server could require players to be next to each other to talk.

User avatar
MineYoshi
Member
Posts: 5373
Joined: Wed Jul 08, 2015 13:20
Contact:

Re: rightclick player menu?

by MineYoshi » Post

PolySaken wrote:
MineYoshi wrote:
theFox wrote:I wanted to ask if anyone would appreciate this...
It would make the game a lot easier, specially the part of giving items.
Maybe the talk option could be used to add realism? a server could require players to be next to each other to talk.
I find this quite annoying. Maybe an option to chat privately being close could be good, let's be honest, but being alone on a mine and not being able to ask someone for help truly isn't so funny at all.
Oi

User avatar
sorcerykid
Member
Posts: 1507
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: rightclick player menu?

by sorcerykid » Post

PolySaken wrote:This would be quite easy to implement with a server side mod. Redefine hand on_secondary_use to check if pointed_thing is a player. Then open a formspec with said options.
Sadly, it's not that easy. I attempted this about a year ago, but never got it to work using the existing API since right-click events are ignored for player objects. I ended up having to add an on_player_rightclick( ) callback to the engine.

From the source files below, you can see that server packet handler intercepts the event and calls the rightClick( ) method of the player object, which is no-op by default.

https://github.com/minetest/minetest/bl ... r.cpp#L987

https://github.com/minetest/minetest/bl ... ect.h#L141

User avatar
PolySaken
Member
Posts: 696
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: rightclick player menu?

by PolySaken » Post

sorcerykid wrote:
PolySaken wrote:This would be quite easy to implement with a server side mod. Redefine hand on_secondary_use to check if pointed_thing is a player. Then open a formspec with said options.
Sadly, it's not that easy. I attempted this about a year ago, but never got it to work using the existing API since right-click events are ignored for player objects. I ended up having to add an on_player_rightclick( ) callback to the engine.

From the source files below, you can see that server packet handler intercepts the event and calls the rightClick( ) method of the player object, which is no-op by default.

https://github.com/minetest/minetest/bl ... r.cpp#L987

https://github.com/minetest/minetest/bl ... ect.h#L141
on_secondary_use overrides other rightlick functions though, does it not?
Edit: sorry, I was wrong. apparently you can't overwrite the hand either.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

Re: rightclick player menu?

by hajo » Post

PolySaken wrote:talk option .. server could require players to be next to each other to talk.
Maybe display a speech-balloon for private / line-of-sight talking ?

Or just craft a sign/book, and write on it...

User avatar
sorcerykid
Member
Posts: 1507
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: rightclick player menu?

by sorcerykid » Post

The on_secondary_use( ) callback is only triggered when the player is pointing at air. If you look further down in the CPP source of the packet handler, you can see it is a special case.

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

Re: rightclick player menu?

by zeuner » Post

theFox wrote:How about a menu that pops up when you rightclick a player?

featuring:
  • whisper
  • give items
  • (admin) kick
  • (admin) peek/open inventory
I like the idea, and I could imagine exciting possibilities of player-player interactions by this.

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

Re: rightclick player menu?

by zeuner » Post

sorcerykid wrote:
PolySaken wrote:This would be quite easy to implement with a server side mod. Redefine hand on_secondary_use to check if pointed_thing is a player. Then open a formspec with said options.
Sadly, it's not that easy. I attempted this about a year ago, but never got it to work using the existing API since right-click events are ignored for player objects. I ended up having to add an on_player_rightclick( ) callback to the engine.

From the source files below, you can see that server packet handler intercepts the event and calls the rightClick( ) method of the player object, which is no-op by default.

https://github.com/minetest/minetest/bl ... r.cpp#L987

https://github.com/minetest/minetest/bl ... ect.h#L141
Do you happen to have a pull request opened for the engine addition? I don't think it's justified to only be able to set "on_rightclick" handlers for non-player objects.
Last edited by zeuner on Mon Aug 27, 2018 17:35, edited 1 time in total.

User avatar
sorcerykid
Member
Posts: 1507
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: rightclick player menu?

by sorcerykid » Post

Here are the changes I made to the engine, with git patches for Minetest 0.4.15 and up: viewtopic.php?f=7&t=20722

Usage is similar to that of Lua entities, except it's a global callback.
  • minetest.register_on_rightclickplayer(func(player, clicker))
I hope you find it useful on your server!

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

Re: rightclick player menu?

by zeuner » Post

sorcerykid wrote:Here are the changes I made to the engine, with git patches for Minetest 0.4.15 and up: viewtopic.php?f=7&t=20722

Usage is similar to that of Lua entities, except it's a global callback.
  • minetest.register_on_rightclickplayer(func(player, clicker))
I hope you find it useful on your server!
Great, thanks!

I'm mostly doing minetest development for allowing people to run the modifications on their servers. So I would still think it would be a valuable contribution to let the patch find its way into the officially distributed server source.

Byakuren
Member
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: rightclick player menu?

by Byakuren » Post

Is item on_place triggered when pointing at players?
Every time a mod API is left undocumented, a koala dies.

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

Re: rightclick player menu?

by zeuner » Post

theFox wrote:How about a menu that pops up when you rightclick a player?

featuring:
  • whisper
  • give items
  • (admin) kick
  • (admin) peek/open inventory
Regarding giving items, you might be interested in a mod I started on: https://github.com/zeuner/structured_communication. It's about giving items to another player in exchange for other items.

User avatar
emperor_genshin
Member
Posts: 75
Joined: Tue Dec 22, 2015 05:04
IRC: Emperor_Genshin - Genshin
In-game: Emperor_Genshin - Genshin
Location: Cyberspace
Contact:

Re: rightclick player menu?

by emperor_genshin » Post

Made my own solution to this for the time being without the need to fiddle with core: https://notabug.org/Genshin/p2p

Example using this mod:

Code: Select all


p2p.register_on_right_clickplayer(function(clicker, clicked)

    minetest.chat_send_player(clicker:get_player_name(), "Right Clicked "..tostring(clicked:get_player_name()))

end)

Wiki: https://notabug.org/Genshin/p2p/wiki/How+to+use+the+api

Example Video: https://www.youtube.com/watch?v=PtzILeR0eWs
Last edited by emperor_genshin on Fri Aug 28, 2020 22:11, edited 3 times in total.
I'm just a individual who likes to make impressive things. | Current Mod: Dungeon Crawl Maker https://www.youtube.com/watch?v=c6g6H2kLBpg

User avatar
sorcerykid
Member
Posts: 1507
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: rightclick player menu?

by sorcerykid » Post

zeuner wrote:I'm mostly doing minetest development for allowing people to run the modifications on their servers. So I would still think it would be a valuable contribution to let the patch find its way into the officially distributed server source.
I have a PR in review which incorporates the patch I shared above. Hopefully it will be merged into 5.4.

https://github.com/minetest/minetest/pull/9569

User avatar
runs
Member
Posts: 2090
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: rightclick player menu?

by runs » Post

sorcerykid wrote:
Fri Aug 28, 2020 20:22
zeuner wrote:I'm mostly doing minetest development for allowing people to run the modifications on their servers. So I would still think it would be a valuable contribution to let the patch find its way into the officially distributed server source.
I have a PR in review which incorporates the patch I shared above. Hopefully it will be merged into 5.4.

https://github.com/minetest/minetest/pull/9569
I hope that this is the case, for me it is fundamental, for the interaction with NPCs and other players without being by commands. For example, right now I have in mind to share objects between inventories.
🤑 Patreon |Minetest Chat | 👧 Samantha | ⛏️ Juanchi Game | 🐱 Petz

User avatar
runs
Member
Posts: 2090
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: rightclick player menu?

by runs » Post

I am thinking on pickpocketing too, as in Skyrim.
🤑 Patreon |Minetest Chat | 👧 Samantha | ⛏️ Juanchi Game | 🐱 Petz

User avatar
runs
Member
Posts: 2090
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: rightclick player menu?

by runs » Post

emperor_genshin wrote:
Fri Aug 28, 2020 19:05
Made my own solution to this for the time being without the need to fiddle with core: https://notabug.org/Genshin/p2p

Example using this mod:

Code: Select all


p2p.register_on_right_clickplayer(function(clicker, clicked)

    minetest.chat_send_player(clicker:get_player_name(), "Right Clicked "..tostring(clicked:get_player_name()))

end)

Wiki: https://notabug.org/Genshin/p2p/wiki/How+to+use+the+api

Example Video: https://www.youtube.com/watch?v=PtzILeR0eWs
I will use It for my pickpocketing mod.
🤑 Patreon |Minetest Chat | 👧 Samantha | ⛏️ Juanchi Game | 🐱 Petz

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest