The Special key (new mod included)

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

The Special key (new mod included)

by texmex » Post

I've some questions about the Special key, the one bound to the physical E key by default.

Was/is there an intended purpose for it? Is there even a way to employ the key to behave like a use key to "use" nodes, like doors?
Last edited by texmex on Fri Mar 01, 2019 23:14, edited 1 time in total.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: The Special key

by GreenXenith » Post

The 'Special key' is the Auxiliary key (shorthand: AUX). It is intended for sprinting.. I am confused as to why you are asking. Have you ever not walked before? :0

As for use: Yes, of course, as are all movement keys. As the Lua API shows, aux1 is returned from get_player_control() and get_player_control_bits() player methods. To use it as a "use" functionality wouldn't be particularly pretty, but certainly possible. Probably something along the lines of a looping node timer with get_objects_inside_radius() would be the most elegant and least intensive (assuming it is node specific).

And just in case you meant mapping the aux key to 'use' locally: No.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: The Special key

by texmex » Post

Yes, I have sprinted before as I wrote hbsprint mod, for example. And no, I need to look for the pointed node, not objects.

I’m partly asking because IIRC the key was called Use key until recently which denotes the intention of feature. I kind of hoped that there was hope for some API support in that direction but it doesn’t seem like it.

Rolling my own solution would be as inaccurate as the WAILA-like mods in existance, because raycasting cannot (yet?) fully emulate what node the client is pointing at. I’ve tried in my mod pointlib but it’s as I said: inaccurate.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: The Special key

by GreenXenith » Post

texmex wrote:no, I need to look for the pointed node, not objects.
You misunderstand. Getting the objects inside the radius was to activate said door when a player is within a certain radius and holding the aux key. Also you never mentioned pointing in the first post, but this can still be accomplished regardless (but not blanketed, as you seem to desire).
Rolling my own solution would be as inaccurate as the WAILA-like mods in existance, because raycasting cannot (yet?) fully emulate what node the client is pointing at. I’ve tried in my mod pointlib but it’s as I said: inaccurate.
I am confused as to what the aux key has to do with WAILA mods, but ok.

Here you go: https://github.com/Jordach/Solar_Plains ... a/init.lua
This utilizes minetest.raycast() (and is therefore only usable in 5.0.0) and should be completely accurate.

EDIT: Post 1234 \o/
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: The Special key

by texmex » Post

But nodes are not objects, nor are objects nodes.

As nodes need to be pointed to in order to interact with them that went without saying.

As I said I already have my own raycasting in the aforementioned pointlib. Why this is needed is to emulate the pointing and selecting of nodes that happens client-side. I’ll still check out this particular implementation to see if it’s more accurate though, thanks.

Now, even is pointing is solved and Special key check is implemented, how would I essentially replace the convention of ”use by right-click” with the new one? I’d need to disable it somehow, while also copy it’s functions in registered_nodes to some new definition like ”on_special”.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: The Special key

by GreenXenith » Post

texmex wrote:But nodes are not objects nor are objects nodes.
You are still stuck on this. Your original post was too vague to give any sort of desired result, so as far as I could tell you wanted things like doors to be able to activate upon the player pressing the aux key. Which is accomplished by the door node detecting the player object and whether or not said player is holding the aux key (and perhaps also pointing at the door). Maybe just forget about it, as it is not even the desired outcome in this situation?
As nodes need to be pointed to in order to interact with them that went without saying.
Not so! In the aforementioned situation the node can be "interacted with" without clicking/pointing at the node. It might, however, be somewhat unwieldy :)
As I said I already have my own raycasting in the aforementioned pointlib. Why this is needed is to emulate the pointing and selecting of nodes that happens client-side. I’ll still check out this particular implementation to see if it’s more accurate though, thanks.
I interpreted that as you making your own raycast rather than using Minetest's method, my bad maybe? Also what:
> Why this is needed is to emulate the pointing and selecting of nodes that happens client-side.

Ninja edit:
Now, even if pointing is solved and Special key check is implemented, how would I essentially replace the convention of ”use by right-click” with the new one? I’d need to disable it somehow, while also copy it’s functions in registered_nodes to some new definition like ”on_special”.
So.. you want both WAILA and use by aux?
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: The Special key

by texmex » Post

Code: Select all

`minetest.get_objects_inside_radius(pos, radius)`: returns a list of
  ObjectRefs.
So just ObjectRefs, not nodes. But let’s not focus on that part.

You’re right that the feature could work without pointing at all, though it would then interact with all nodes around the player, at the same time.

How can the door node be made to detect anything? Node timer? ABM? It sounds very backwards to not use the player for starting point.

But pointed_thing is only retrieved if first interacting with the node, not when only selecting it.

Ninja reply: Forget WAILA itself. What I said was: ”as inaccurate as the WAILA-like mods” when referring to techniques for finding the pointed thing. But I guess you could say I want that in a way, technically.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: The Special key

by GreenXenith » Post

texmex wrote:

Code: Select all

`minetest.get_objects_inside_radius(pos, radius)`: returns a list of
  ObjectRefs.
So just ObjectRefs, not nodes. But let’s not focus on that part.

You’re right that the feature could work without pointing at all, though it would then interact with all nodes around the player, at the same time.

How can the door node be made to detect anything? Node timer? ABM? It sounds very backwards to not use the player for starting point.
That edit dance was no help :)
Unfortunately, you have to focus on that part.
From my post:
GreenDimond wrote:as far as I could tell you wanted things like doors to be able to activate upon the player pressing the aux key. Which is accomplished by the door node detecting the player object and whether or not said player is holding the aux key (and perhaps also pointing at the door).
And from my original reply:
GreenDimond wrote:Probably something along the lines of a looping node timer with get_objects_inside_radius() would be the most elegant and least intensive (assuming it is node specific)
The solution only works when you specify it inside the node. The node itself looks for players within it's specified radius and runs the check on the found players. And yes, it is very backwards. Again, it does not blanket well.

Alternatively, but also perhaps more intensive, you can use a globalstep looping through all players that gets the pointed thing (be it raycast, or what have you) and does minetest.registered_nodes[node.name].on_rightclick() if it exists.

If you wish to disable the rightclick function as well you can create your own table of nodes. If you end up using 5.0.0 there is a nifty minetest.register_on_mods_loaded(function()) function in which you can loop through all registered nodes, find ones with on_rightclick, copy them to a table you make yourself, and minetest.override_item() the on_rightclick.
But pointed_thing is only sent if first interactibg with it, not continously.
Hm, I guess so! Never mind on that, then :)
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: The Special key

by GreenXenith » Post

Double post to avoid editing headaches: minetest.raycast() returns a list pointed_things, I think. Which means it can be sent "continuously". The on_rightclick() function takes the args function(pos, node, clicker, itemstack, pointed_thing), meaning you would need to pass all of those in order for things to not break. While pos, node, clicker, and itemstack are viable to pass, originally pointed_thing would not have been. However, if you use raycast (which you should ;)), none of the args should be a problem.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: The Special key

by sofar » Post

GreenDimond wrote:The 'Special key' is the Auxiliary key (shorthand: AUX). It is intended for sprinting.
I don't think this is correct. While it is used by several mods for this, I do not believe that that is why it exists in the first place, nor that that was even a consideration for why it was added.

Simply, I believe it was added to allow another way to use items in hand or things around the player, much like how `e` is a popular way to interact with random things in the environment, in many, many games. Having only left and right click is obviously very restrictive, so I'm convinced that is why this special key was added.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: The Special key

by GreenXenith » Post

sofar wrote:
GreenDimond wrote:The 'Special key' is the Auxiliary key (shorthand: AUX). It is intended for sprinting.
I don't think this is correct. While it is used by several mods for this, I do not believe that that is why it exists in the first place, nor that that was even a consideration for why it was added.

Simply, I believe it was added to allow another way to use items in hand or things around the player, much like how `e` is a popular way to interact with random things in the environment, in many, many games. Having only left and right click is obviously very restrictive, so I'm convinced that is why this special key was added.
I mean, that has been it's primary function since it was introduced (maybe from the beginning?). Aux1 is literally bound to sprinting. Hard-coded. I find it hard to believe someone said "let's add an extra control for mod use... and hard-code it to sprint just because". I dunno, an answer from a dev that knows for certain or logs or PR/issue or something would be nice.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
Calinou
Moderator
Posts: 3169
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou
Location: Troyes, France
Contact:

Re: The Special key

by Calinou » Post

sofar wrote:
GreenDimond wrote:The 'Special key' is the Auxiliary key (shorthand: AUX). It is intended for sprinting.
I don't think this is correct. While it is used by several mods for this, I do not believe that that is why it exists in the first place, nor that that was even a consideration for why it was added.
The Special key was also used to descend ladders until early 0.4.x releases (where the Sneak key now descends ladders by default).

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: The Special key

by ShadMOrdre » Post

IMHO, sprint should be double tap W. Press W to walk, double tap W to walk fast. This is intuitive, and other games use this mechanic, including the android version of MT.

texmex, would you support this?

This then opens E to be interpreted by the wield item, pointed thing, or a combination of both.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: The Special key

by texmex » Post

ShadMOrdre wrote:IMHO, sprint should be double tap W. Press W to walk, double tap W to walk fast. This is intuitive, and other games use this mechanic, including the android version of MT.

texmex, would you support this?

This then opens E to be interpreted by the wield item, pointed thing, or a combination of both.
I’d support this, yes. It’s too useful to be wasted on something as simple as sprinting. I’ve yet to implement it as a feature in hbsprint, but I want to.

The problem with pointed thing still stands though, as it’s only sent on click.

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: The Special key

by sofar » Post

GreenDimond wrote:I mean, that has been it's primary function since it was introduced (maybe from the beginning?). Aux1 is literally bound to sprinting. Hard-coded.
That's not even remotely near the truth. The minetest engine only hardcodes `aux1 ladder descend` and that is even optional. There is nothing in the engine that binds aux1 to sprinting. The word "sprint" isn't even in the code (it's mentioned in one commit message that has nothing to do with aux1 code or player speed).

On top of that, minetest_game does not even implement sprinting. Nor does it handle aux1. There is not a single git commit in minetest_game that mentions aux1 or sprint.

Really, your statement is entirely false and 2 minutes of reading through git logs shows this.

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: The Special key

by ShadMOrdre » Post

Sofar and GreenDimond,

You are both right and both wrong. And I think there is confusion about sprinting vs. the Walk Fast priv.

While sprinting is not part of MT or MTG, the walk fast priv exists even in MTDev, so this must then be hardcoded in builtin, which just means this behavior is easily overridden.

Ideally, the E key is checked in the on_ function of the item being "used", much like the behavior of some mods when they check for whether LShift (sneak) is active.

texmex,

There is also the on_secondary_use function that is available for when you are pointing at "air" or "CONTENT IGNORE". However, I've not found consistency when this function is called and there is also a on_punch, on_use, or on_place function that is defined.

Also, look at the place_rotated mod. There are two versions of the mod, one that uses raycast from v5, and one that uses trigonometry and works on v0417. I use the latter option to create the craft table here. And while that code needs work, I was able to use place_rotated, or rather its function 'place_rotated.get_point(pointed_thing.above,pointed_thing.under,clicker)' to tile the node face so that items can be placed on the table by clicking on the appropriate square.

And further, look at minetest.find_all_nodes_in_area. Instead of GreenDimonds entity finder, this gets you the node finder that your door would require. Using position of player, the position of the door that you want to open, you can quickly determine which door, out of the table returned from find_all_nodes_in_area.

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: The Special key

by GreenXenith » Post

sofar wrote:
GreenDimond wrote:I mean, that has been it's primary function since it was introduced (maybe from the beginning?). Aux1 is literally bound to sprinting. Hard-coded.
That's not even remotely near the truth. The minetest engine only hardcodes `aux1 ladder descend` and that is even optional. There is nothing in the engine that binds aux1 to sprinting. The word "sprint" isn't even in the code (it's mentioned in one commit message that has nothing to do with aux1 code or player speed).

On top of that, minetest_game does not even implement sprinting. Nor does it handle aux1. There is not a single git commit in minetest_game that mentions aux1 or sprint.

Really, your statement is entirely false and 2 minutes of reading through git logs shows this.
Obviously it isn't called "sprinting", it doesn't take a genius to figure out that "sprint" is "fast move". And when did I say minetest_game implements sprinting? Or handle aux1?

Your response comes across very rude, it is not appreciated.
ShadMOrdre wrote:Sofar and GreenDimond,

You are both right and both wrong. And I think there is confusion about sprinting vs. the Walk Fast priv.

While sprinting is not part of MT or MTG, the walk fast priv exists even in MTDev, so this must then be hardcoded in builtin, which just means this behavior is easily overridden.

Ideally, the E key is checked in the on_ function of the item being "used", much like the behavior of some mods when they check for whether LShift (sneak) is active.
What on earth is "MTDev"? Fast move is part of the engine.
The "E key" means nothing here, aux1 is whatever you decide to bind it to;

May I point both you and sofar to this line in content_cao.cpp which clearly shows that aux1 is bound to "sprinting".
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
v-rob
Developer
Posts: 970
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: The Special key

by v-rob » Post

ShadMOrdre wrote:IMHO, sprint should be double tap W. Press W to walk, double tap W to walk fast.
I personally don't like this idea. It may sound good in theory, but it is more time consuming. To stop running but continue walking, you have to let go of W and then start holding W again. Or if you are walking and want to start running, you have to let go of W before tapping it twice.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: The Special key

by ShadMOrdre » Post

GreenDimond,

Honestly, it has been you who has come across as rude, since your first reply to texmex.

Code: Select all

			bool allow_update = false;

			// increase speed if using fast or flying fast
			if((g_settings->getBool("fast_move") &&
					m_client->checkLocalPrivilege("fast")) &&
					(controls.aux1 ||
					(!player->touching_ground &&
					g_settings->getBool("free_move") &&
					m_client->checkLocalPrivilege("fly"))))
					new_speed *= 1.5;
			// slowdown speed if sneeking
			if (controls.sneak && walking)
new_speed /= 2;
Update your copy.

Me typing E in reference to aux1 is what most people get, but you apparently had to say something completely irrelevantly negative in response to a very common assumption. Why even say something on this?

MTDev. Excuse me. Are You Anal? minimal development test Game. Look it up. it comes with MT, alongside MTG. Duh!?!

Obviously, since you referenced sprinting, and never made the aforementioned distinction between sprinting and Walk Fast, it is rather rude of you to then explain yourself away because others were mislead by your confusion.



E, aux1, call it what ever. It is a control key that was made available for modders, and should not be overridden by builtin or the engine or a single mod. It should remain available for use by in game objects, to distinguish various player actions and/or intent.

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: The Special key

by sofar » Post

GreenDimond wrote: May I point both you and sofar to this line in content_cao.cpp which clearly shows that aux1 is bound to "sprinting".
hah, I stand corrected.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: The Special key

by texmex » Post

Getting back on topic, I appreciate the advice given by Shad. Thanks! I will try an approach where I with globalstep check for the aux key being pressed, then check if something is pointed at by means of raycasting, then execute that node’s on_aux definition and execute that function. I’ll also look into moving on_use functions of nodes to on_aux in order to not duplicate functionality.

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: The Special key

by sofar » Post

texmex wrote:Getting back on topic, I appreciate the advice given by Shad. Thanks! I will try an approach where I with globalstep check for the aux key being pressed, then check if something is pointed at by means of raycasting, then execute that node’s on_aux definition and execute that function. I’ll also look into moving on_use functions of nodes to on_aux in order to not duplicate functionality.
Right. This is the right design. If this is working correctly, we should move it into the engine.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: The Special key

by texmex » Post

Well that wasn't hard: auxuse (Don't forget to load pointlib as well). With this mod right-click imply placing and only placing. No more Shift-clicking just to place a node beside a chest, door, trap door or anything using on_rightclick.

Next step would be to improve the pointlib method, suggestions appreciated.
sofar wrote:Right. This is the right design. If this is working correctly, we should move it into the engine.
Which part do you mean should go into the engine?

sofar
Developer
Posts: 2146
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: The Special key

by sofar » Post

texmex wrote:
sofar wrote:Right. This is the right design. If this is working correctly, we should move it into the engine.
Which part do you mean should go into the engine?
The part that, on the server side, detects that aux was pressed while looking at a node, and then directly calls the on_aux_press() callback of the node (or whatever name is decided).

That would remove the need for a lua globalstep, and the server already does this every server step anyway.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: The Special key (new mod included)

by texmex » Post

That would be excellent. Not only for the on_aux feature itself but also, if I understand this correctly, it woulf mean a proper ”looking at” raycast. My implementation in pointlib is quite inaccurate.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests