Thread: Keydown?
View Single Post
  #6  
Old 07-30-2004, 09:06 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Silver Knight
Yes, you'll want to use keypressed.
From commands.rtf:
keydown(key) "the specified key is pressed (0..10: up,left,down,right,S,A,D,M,tab,Q,P)"
So, yes, Q would be 9.

If you want to use other letters not specified in the above info, you would use keydown2.
The syntax for keydown2 is similar, keydown2(keycode,ignorecase);
So, with that, and using the keycode() thing, you can do things like:
NPC Code:

if (keypressed) {
if (keydown2(keycode(x),true)) {
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,Stuff,;
}
}



In that code, it would check to see if a key was pressed (keypressed), then would check in the x button was pressed (keydown2(keycode(x),true)) and would ignore the case, so X would work as well.
If all that was true, it would do the triggeraction.
I will note that keydown2 is good for checking specific keys, and keydown is good for if you want to check the keys set in graal options so regardless of what the person has set for the q-menu (maybe a joystick button), the script will work the way you want.
Reply With Quote