Scripts / Help with how to rebind key to autorun?

Author
Message
Kesstryl
9
Years of Service
User Offline
Joined: 29th Jul 2015
Playing:
Posted: 3rd Aug 2015 06:34 Edited at: 4th Aug 2015 05:10
Edit - See further down for my work in progress code

I'm new (to this engine and to lua, I understand some php/mysql programming as my background) and while I've poked around the some of the scripts here to learn how things work, I would like advice on how to create a script to be able to rebind a key to autorun (instead of having to hold down shift all the time, for example, in most games I play I rebind an autorun so I only have to hit the key once and my character will stay in run mode until I hit the key again).


PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 3rd Aug 2015 17:56 Edited at: 3rd Aug 2015 17:57
This is like a 'state' situation. Hint: Set up a state variable (e.g. e_state=1) so that when the player presses the desired key to run e.g. E key , then use SetCharacterToRun(entity index). Then change the state variable to 0 e.g. e_state=0, when the player presses E again and then use SetCharacterToWalk(entity index) or whatever the desired animation is you want. That is just the very basic foundation for the code, you will probably need to do more.

I think this is what you mean, but please correct me if I'm wrong.
Professional Programmer: Languages- SAS, C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro, Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen).
Kesstryl
9
Years of Service
User Offline
Joined: 29th Jul 2015
Playing:
Posted: 3rd Aug 2015 20:39
Actually this helps a lot, I'll see what I can come up with
PM
Kesstryl
9
Years of Service
User Offline
Joined: 29th Jul 2015
Playing:
Posted: 3rd Aug 2015 21:23 Edited at: 4th Aug 2015 05:09
Instead of autorun, I thought I would first try just toggling run on and off without holding shift. It's not working. I basically put the script on a rock, set the rock to be dynamic, and always active yes. I could use a pointer on why this will not work.

PM
Inertia
9
Years of Service
User Offline
Joined: 12th Jul 2015
Location: SoCal, USA
Posted: 4th Aug 2015 14:30
I believe that SetCharacterToRun() is intended for NPCs only, mate.
Win 10 x64 | i5 @3.3GHz | 4GB RAM | GTX580 1.5 GB
PM
Kesstryl
9
Years of Service
User Offline
Joined: 29th Jul 2015
Playing:
Posted: 4th Aug 2015 20:34
That would explain why it doesn't work, thanks for the tip. I'll just set the walk speed to faster for now
PM

Login to post a reply

Server time is: 2024-12-22 01:24:00
Your offset time is: 2024-12-22 01:24:00