HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

how to detect a button held down

10-30-2004, 04:12 AM#1
311
I want it so if you hold the left arrow key down, you keep moving left, however I dont know how to detect if the button is held down or not just if its pressed.

ps. what is the code for attack move and stop, so I can remove them
10-30-2004, 06:40 AM#2
Guest
I want it so if you hold the left arrow key down, you keep moving left, however I dont know how to detect if the button is held down or not just if its pressed.

ps. what is the code for attack move and stop, so I can remove them


The way I did it was to use 3 triggers. On, off and what on does.

Detects if the button is pressed
Code:
player 1 presses the left arrow key
set integer (variable) to 1

Detects if the button is released
Code:
player 1 releasesthe left arrow key
set integer (variable) to 0

if the buttom is pressed (variable) to keeps firing off.
Code:
timmer - every 1 sec game time
if - integer (variable) = 1
then - move you whatever
else - nothing

Hope this helps you.
10-30-2004, 07:05 AM#3
311
is it possible to do movement through W A S D? That's how I want it, arrow keys I cant stand the position of them on the keyboard. I don't see a "key is released" event for the W A S D keys though, and cant figure out anyway to make 1. Also the "force ui key" event dont allow arrow keys, only allows letters, so I cant do it that way.
10-30-2004, 02:10 PM#4
Gandalf2349
The only way you can detect letters on the keyboard is give the unit dummy abilities, and give them the hotkeys. But even then you can't detect pressed and released, only pushed. But if you did want to do that, you can remember A is attack and S is stop so you have 2 already.

I'd just go with the arrow keys.

P.S. What's wrong with the arrow keys? Maybe turn off Num Lock and use the arrow keys there. I don't know if you like them better.
10-31-2004, 02:39 AM#5
Ant
The only way to detect keys releeased is to use a 3rd party program like FPS Mod :D which makes it only single player. Otherwise use the arrow keys.

Unit abilities aren't that good. For me, I use a shop and select the shop and detect when items are bought to find out if a key has been pressed.