Page 1 of 1

Autorun

PostPosted: Sat Sep 12, 2015 08:04
by duane
If anyone, like myself, misses WoW's autorun key, it's pretty easy to add, if you're willing to compile minetest.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
--- game.cpp    2015-09-12 02:50:54.205681153 -0500
+++ game.cpp.new        2015-09-12 02:46:24.224342387 -0500
@@ -1236,6 +1236,9 @@
                KEYMAP_ID_SPECIAL1,
                KEYMAP_ID_SNEAK,
 
+               //djr
+               KEYMAP_ID_AUTORUN,
+
                // Other
                KEYMAP_ID_DROP,
                KEYMAP_ID_INVENTORY,
@@ -1287,6 +1290,9 @@
        key[KEYMAP_ID_SPECIAL1]     = getKeySetting("keymap_special1");
        key[KEYMAP_ID_SNEAK]        = getKeySetting("keymap_sneak");
 
+       // djr
+       key[KEYMAP_ID_AUTORUN]      = getKeySetting("keymap_autorun");
+
        key[KEYMAP_ID_DROP]         = getKeySetting("keymap_drop");
        key[KEYMAP_ID_INVENTORY]    = getKeySetting("keymap_inventory");
        key[KEYMAP_ID_CHAT]         = getKeySetting("keymap_chat");
@@ -2616,6 +2622,10 @@
 
        if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_DROP])) {
                dropSelectedItem();
+       // djr
+       } else if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_AUTORUN])) {
+               bool autorun_setting = g_settings->getBool("continuous_forward");
+               g_settings->setBool("continuous_forward", !autorun_setting);
        } else if (input->wasKeyDown(keycache.key[KeyCache::KEYMAP_ID_INVENTORY])) {
                openInventory();
        } else if (input->wasKeyDown(EscapeKey) || input->wasKeyDown(CancelKey)) {


I also added a change to disable the scroll wheel, because I keep activating my trackpad's scroll by mistake.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
@@ -2704,7 +2714,8 @@
         */
        *new_playeritem = client->getPlayerItem();
 
-       s32 wheel = input->getMouseWheel();
+       //s32 wheel = input->getMouseWheel();
+       s32 wheel = 0;
        u16 max_item = MYMIN(PLAYER_INVENTORY_SIZE - 1,
                                 player->hud_hotbar_itemcount - 1);


You'll also want to add a key setting to your minetest.conf file, replacing the "P" with your key choice.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
keymap_autorun = KEY_KEY_P


This seems to work fine on my system, and I can't imagine any reason why it wouldn't work on windoze, but it's obviously not useful for android. However, I may discover that it screws everything up tomorrow, so use at your own risk.

I'm sure somebody has done this before, but I've searched for days and couldn't find it.

Re: Autorun

PostPosted: Sat Sep 12, 2015 08:38
by nrz
I suggest you to do a PR and propose this patch on github, could be useful !

Re: Autorun

PostPosted: Sat Sep 12, 2015 11:42
by duane
I have the feeling that there's a reason why they never added this. The basic behavior was already there. It was easy to tie it to a key. Maybe they're afraid of people logging in to servers and autorunning across the landscape until the mapgen chokes on it and the whole server crashes.

Re: Autorun

PostPosted: Sat Sep 12, 2015 15:04
by Sokomine
duane wrote:If anyone, like myself, misses WoW's autorun key, it's pretty easy to add, if you're willing to compile minetest.

That's great! I've wished for an auto-run-key for a long time. It is very annoying to press a key for a long time.

duane wrote:This seems to work fine on my system, and I can't imagine any reason why it wouldn't work on windoze, but it's obviously not useful for android. However, I may discover that it screws everything up tomorrow, so use at your own risk.

It could even be particulary intresting on Android. Maybe in combination with reaction to the motion sensors. Normal walking could still worlk through the keys, but getting to the area of intrest could be a lot easier and more immersive that way.

nrz wrote:I suggest you to do a PR and propose this patch on github, could be useful !

By all means!

duane wrote:I have the feeling that there's a reason why they never added this. The basic behavior was already there. It was easy to tie it to a key. Maybe they're afraid of people logging in to servers and autorunning across the landscape until the mapgen chokes on it and the whole server crashes.

Don't worry. That won't happen in practice on realistic maps. The next hole will be there - and the player will fall into it, forever running against a wall. Or the next best tree. Or drowning in the next ocean. It's just a matter of time.

Re: Autorun

PostPosted: Tue Sep 29, 2015 11:38
by duane
If anyone is interested in getting this into the main code base, I suggest you comment on this pull request.

Re: Autorun

PostPosted: Tue Sep 29, 2015 13:28
by Ferk
So this toggles a continue-walking mode? I've never seen something like that, I'll have to test this. But I have a feeling this mostly makes sense for games that are very mouse-oriented, I think there should be a way to open the inventory with the mouse for this to be more interesting.

Btw.. coincidentally F is the key I always use for the inventory. R and E are also assigned. If this gets included as the F key I guess I'll have to use C or X.. I refuse to go to the other side of the keyboard for something I press so much. And I'd rather not reconfigure all the keys. What do you guys use for the inventory key?

Re: Autorun

PostPosted: Tue Sep 29, 2015 17:16
by kaadmy
I use a laptop, so the side of the keyboard doesn't matter much at all for me, moving my hand a few inches isn't a problem :)
Maybe pressing any normal movement key should disable autorun? With duane's build, it got turned on and I couldn't figure out why :)

Re: Autorun

PostPosted: Tue Sep 29, 2015 18:38
by duane
kaadmy wrote:Maybe pressing any normal movement key should disable autorun? With duane's build, it got turned on and I couldn't figure out why :)


I think so too, but that's more work than I'm willing to put into it right now. This patch only attaches the existing feature to a key. I have a lot of trouble following the game code.

I dislike putting any default at all on it, but the standard check for a key setting uses the version that throws errors rather than just dropping out gracefully. I'm probably missing something there.

Re: Autorun

PostPosted: Tue Sep 29, 2015 18:50
by kaadmy
duane wrote:I dislike putting any default at all on it, but the standard check for a key setting uses the version that
throws errors rather than just dropping out gracefully. I'm probably missing something there.

Would assigning autorun to an empty setting break anything, or would it assume nothing's bound to it and peacefully continue?

Re: Autorun

PostPosted: Tue Sep 29, 2015 19:51
by Amaz
toggle_camera_update is assigned to no key in non-debug builds, maybe this helps?
https://github.com/minetest/minetest/bl ... pp#L57-L62

Re: Autorun

PostPosted: Tue Sep 29, 2015 21:05
by duane
That does work, thanks. I set the default after someone pointed out that minetest crashed when there was no default or setting in minetest.conf. It didn't occur to me to make it blank.

Re: Autorun

PostPosted: Tue Oct 27, 2015 22:36
by duane
The pull request on github has gone 19 days without comment. Autorun is not a universally desired feature, so if anyone else wants to see this, now would be a good time to comment on github.

Re: Autorun

PostPosted: Wed Oct 28, 2015 06:36
by Linuxdirk
duane wrote:The pull request on github has gone 19 days without comment

Sometimes it feels like that pull requests get ignored until there is a multi-page discussion about it in the forums.

Re: Autorun

PostPosted: Wed Oct 28, 2015 09:25
by rubenwardy
19 days is typical for a new feature, you need to pester core devs in #minetest-dev to approve it.

Re: Autorun

PostPosted: Thu Oct 29, 2015 20:51
by sfan5
(づ。◕‿‿◕。)づ commit b6dfae0

Re: Autorun

PostPosted: Thu Oct 29, 2015 23:12
by duane
sfan5 wrote:(づ。◕‿‿◕。)づ commit b6dfae0


Woot!

Re: Autorun

PostPosted: Fri Oct 30, 2015 08:52
by lightonflux
When autorun is toggle and i press the forward key the char runs with fast walking speed is this intended behaviour?

Edit: And there is no walking animation. So i prepare for interesting discussions on servers. :)

Re: Autorun

PostPosted: Sun Nov 01, 2015 10:25
by duane
lightonflux wrote:When autorun is toggle and i press the forward key the char runs with fast walking speed is this intended behaviour?

Edit: And there is no walking animation. So i prepare for interesting discussions on servers. :)


The "autorun" is actually the continuous_forward function, so it lacks a lot of amenities. It was easy to implement since it only required toggling an existing setting. I considered making the forward key toggle it off, but that would affect its original uses as well.

Re: Autorun

PostPosted: Sun Nov 01, 2015 15:58
by Linuxdirk
duane wrote:but that would affect its original uses as well.

Don't break the game for the majority of players to implement a feature only a few would actually use.

Re: Autorun

PostPosted: Mon Nov 02, 2015 01:20
by duane
Linuxdirk wrote:Don't break the game for the majority of players to implement a feature only a few would actually use.


Absolutely. Although, I doubt that there were as many people using continuous_forward as there are using autorun (i.e. a few developers, at most).

Re: Autorun

PostPosted: Fri Nov 06, 2015 20:34
by Sokomine
A long awaited feature has finally made it into the game! Thank you! That will help my fingers and my keyboard a lot. Pressing a key for such a long time was very tiring. That's diffrent from steering now and then!

Only issue, though: I wouldn't have noticed that the feature got finally added to the game without reading the thread (or taking a look at the commits). Adding it to the keymap setting and documentation would be good.

For those intrested: I mapped it to Q in my minetest.conf (close to w; and dropping is on L for loose item anyway).

Again: Thanks! And thanks to the devs for merging!