How to get player highlighted node?
How to get player highlighted node?
When player pointed to node then node becomes with borders or highlighted I would like to get meta data (at least node name) about that node. I must be missed on lua API documentation. Anyone can point me to right API to achieve what I looking?
- stu
- Member
- Posts: 923
- Joined: Sat Feb 02, 2013 02:51
- GitHub: stujones11
- Location: United Kingdom
Re: How to get player highlighted node?
This is possible with ray-casting https://github.com/minetest/minetest/bl ... .txt#L2720xeranas wrote:When player pointed to node then node becomes with borders or highlighted I would like to get meta data (at least node name) about that node. I must be missed on lua API documentation. Anyone can point me to right API to achieve what I looking?
Simply cast a ray along the player's line of sight and return the first blocking node/object. However, since this is server-side, there may be some discrepancy between client and server due to lag.
Client side modding might be better suited to this task as the pointed node info is already known by the client and is available in the F5 debug info. I am not sure if this is accessible with current CSM but I believe it has been suggested.
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: How to get player highlighted node?
Should note that minetest.raycast is not available in the stable version.
Every time a mod API is left undocumented, a koala dies.
- stu
- Member
- Posts: 923
- Joined: Sat Feb 02, 2013 02:51
- GitHub: stujones11
- Location: United Kingdom
Re: How to get player highlighted node?
That is a very fair and valid point, if backwards compatibility is a concern then you could use good old `minetest.line_of_sight` to the same end, however, this does not have the same selection-box level of accuracy as `minetest.raycast` and cannot detect entities.Byakuren wrote:Should note that minetest.raycast is not available in the stable version.
- stu
- Member
- Posts: 923
- Joined: Sat Feb 02, 2013 02:51
- GitHub: stujones11
- Location: United Kingdom
Re: How to get player highlighted node?
Admittedly, the OP does not say that they require this information without using a tool to click on the highlighted node. If that is not the case then `pointed_thing` might well be what they are looking for.
-
- Member
- Posts: 818
- Joined: Tue Apr 14, 2015 01:59
- GitHub: raymoo
- IRC: Hijiri
- In-game: Raymoo + Clownpiece
Re: How to get player highlighted node?
He says that he wants to know the metadata of nodes when the user looks at them ("becomes with borders or highlighted"), which I think means before the player clicks on it. But it also doesn't look like he needs an intersection point, so minetest.line_of_sight would probably suffice.
Every time a mod API is left undocumented, a koala dies.
Re: How to get player highlighted node?
Thanks for answers I probably try both variants and see how its goes. Ideally for my case it would be perfect something like "player.get_pointed_thing(above)" as I would like to know 'pointed_thing' before actually using tool. I feel that it is bit unwise in performance to re-calculate 'my pointed node' via other generic purpose api methods like minetest.line_of_sight / minetest.raycast to get what engine already knows, F5 pointing_at tells exacly what node I'm pointing at.
- Krock
- Developer
- Posts: 4650
- Joined: Thu Oct 03, 2013 07:48
- GitHub: SmallJoker
- Location: Switzerland
- Contact:
Re: How to get player highlighted node?
While this is true for the client-sided modifications, it won't work for server mods, as the server does not calculate the pointed node of each player. Notice that the raycast function/object can also be used to calculate the shooting line of an object, if the collision detection is too inefficient/slow for this task.xeranas wrote:F5 pointing_at tells exacly what node I'm pointing at.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: How to get player highlighted node?
What's wrong with getting the pointed_thing when using the tool and then decide in the tool's function what to do?xeranas wrote:as I would like to know 'pointed_thing' before actually using tool.
Re: How to get player highlighted node?
To my understanding you must use mouse click to invoke callback where 'pointed' object will be returned. That alone is big restriction. If I would need mark-and-perform action it would take 3 steps: 1 select correct tool, 2 mouse click to invoke on use (perform mark action), 3 mouse click to invoke un_use (check if there marked area then perform action, mark otherwise). IMO it would be useless 'helper' category tool if I would need at least 2 mouse clicks to perform simple action.Linuxdirk wrote:What's wrong with getting the pointed_thing when using the tool and then decide in the tool's function what to do?xeranas wrote:as I would like to know 'pointed_thing' before actually using tool.
I was thinking about mod similar to builders wand*:
https://youtu.be/_hDrbP7ql40?t=9m40s
The main thing what I like about builders wand is it let player fast see where blocks will be placed before it actually placed (without additional mouse/keyboard clicks).
*let me know if such mod exist on minetest
- stu
- Member
- Posts: 923
- Joined: Sat Feb 02, 2013 02:51
- GitHub: stujones11
- Location: United Kingdom
Re: How to get player highlighted node?
Unfortunately, I am not sure either method would be suitable for this due the aforementioned lag. Something like this would currently need to be done in the engine itself, however, it may one day be possible using CSM. This is, after all, what client-side modding should be good for.xeranas wrote: I was thinking about mod similar to builders wand*:
https://youtu.be/_hDrbP7ql40?t=9m40s
The main thing what I like about builders wand is it let player fast see where blocks will be placed before it actually placed (without additional mouse/keyboard clicks).
- Linuxdirk
- Member
- Posts: 3219
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: How to get player highlighted node?
All the information is already there (debug screen). it just has to be made accessible via the API.
- stu
- Member
- Posts: 923
- Joined: Sat Feb 02, 2013 02:51
- GitHub: stujones11
- Location: United Kingdom
Re: How to get player highlighted node?
Indeed, that and a way to produce the visuals without (ab)using server-side entities.Linuxdirk wrote:All the information is already there (debug screen). it just has to be made accessible via the API.
Who is online
Users browsing this forum: rudzik8 and 6 guests