Bind alt to toggle walk on/off

I would like a script that will make the alt key toggle walking on and off, instead of having to hold it.

I’m not sure if this works or not, I just tried to throw something together. Put it at the bottom of garrysmod/cfg/config. Since i’m a lua noob, I used alias.

bind alt “wt1”
alias wt1 “+walk;bind alt wt2”
alias wt2 “-walk;bind alt wt1”

Wow, that’s really sneaky. I’ll try that out since I’m hopping on GMod now.

Heh, i cant belive someone just figured this out XD, I think aliases are the easiest thing to do. But yeah that should work.

I know about aliases and have a few, just that I’ve never thought of re-binding a key to make a toggle.

You may have to retype the alias’ in console.

autoexec.cfg for epic win?

Every time I alt-tab (which is a lot) the bind fails itself, so I come back to this thread through the Steam browser and put the lines in the console manually :stuck_out_tongue:

So I should put this in autoexec.cfg instead, then? I’ll just try that.

this is probably the best place to put it rather than making a new thread, could you do the same with crouch/shift

Just change +walk to +speed for sprint, and +duck for crouch.

Would there be a way to make it so I can hold it if I wish? This is of course because I use Sakarias’s Air Vehicles and to lower throttle is alt. With the helicopters I literally fall out of the sky as soon as I turn it on, but with jets it’s fine and I don’t care, it actually makes it really easy to land.

So it would retain both functionalities - holding, and toggling. Say walk was not turned on and I held it, it would turn on until I let go. And if it is on, I can hold it to turn it off, and when I let go, it will go back to walking again.

If that isn’t possible then it’s alright I guess.

You need LUA on that one, alias cannot do it.