Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   onKeyPressed() (https://forums.graalonline.com/forums/showthread.php?t=87512)

[email protected] 08-22-2009 01:04 PM

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.


All times are GMT +2. The time now is 07:00 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.