Thread: onKeyPressed()
View Single Post
  #16  
Old 08-22-2009, 01:04 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
What're you trying to do? If you're wanting for it to operate with Graals origional keys (those that you can change using the 'F3/Change Keys' option) you'll need to use keydown(variable).

Here's a couple of examples to show this
HTML Code:
function onKeyPressed() {
  temp.dirs = {"Up", "Left", "Down", "Right"};
  for (temp.dir = 0; temp.dir < 4; temp.dir++) {
    if (keydown(temp.dir)) {
      player.chat = "Pressed" @ temp.dirs[temp.dir];
    }
  }
}
HTML Code:
function onKeyPressed() {
  if (keydown(0)) player.chat = "Moving up";
  elseif (keydown(1)) player.chat = "Moving left";
  elseif (keydown(2)) player.chat = "Moving down";
  elseif (keydown(3)) player.chat = "Moving right";
}
Here are the keydown variables:
0, 1, 2 & 3 are all movement keys
4 is 'A'
5 is 'S'
6 is 'D'
7 is the map key [default- 'M']
8 is the tab key (chat toggle)
9 is the inventory [default- 'Q']
10 is for pausing [default- 'P']

Hope this helps.
Reply With Quote