Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Key numbers? (https://forums.graalonline.com/forums/showthread.php?t=87249)

[email protected] 08-04-2009 03:43 PM

Key numbers?
 
Hey guys, jamerson here. I am making a movement system that will make the players movement faster then the default, and I need to know:

What are the key names for up,down,left, and right? I am going to do keydown but I can't seem to get it right.

I would appreciate any help I can get.

Thanks much,

-Jameson61894

Crow 08-04-2009 04:07 PM

You should probably go for keydown(), the numbers to use with it are the same as the direction numbers of players/npcs (0-3).

[email protected] 08-04-2009 04:38 PM

Appreciate it bro.

Gambet 08-04-2009 05:12 PM

You could use a loop like such:

PHP Code:

//#CLIENTSIDE
function onKeyPressed() {
  for (
temp.key 0temp.key 4temp.key++) {
    if (
keydown(key)) { //If the player has pressed a movement key
      //Do Stuff
    
}
  }



Skyld 08-04-2009 06:59 PM

If I remember correctly, the onKeyPressed() keycodes are 37, 38, 39 and 40.

Gambet 08-04-2009 07:17 PM

Quote:

Originally Posted by Skyld (Post 1512912)
If I remember correctly, the onKeyPressed() keycodes are 37, 38, 39 and 40.


Hmm? The code I posted works just fine.

Skyld 08-04-2009 07:33 PM

Quote:

Originally Posted by Gambet (Post 1512916)
Hmm? The code I posted works just fine.

Yes, because you are using keydown(). If you use the onKeyPressed(temp.keycode) parameter, then temp.keycode will probably be 37-40 for the D-pad.

fowlplay4 08-04-2009 07:42 PM

Well if he's making a movement system he's going to want to check for the keys in a timeout anyway, or else you get weird holding behavior.

DustyPorViva 08-04-2009 08:01 PM

Ya, onKeypressed() functions off of the keyboard preferences on the OS, much like actual typing. So if you have onKeypressed(), and you hold down S, it will input S, then after a moment repeatedly call the function over and over, just like holding down S would do in a text editor. The speed of which it does this depends purely on how the persons keyboard is set-up, so it would not function the same for everyone -- not ideal for movement at all.

WhiteDragon 08-05-2009 04:47 AM

GraalControl.onKeyDown and GraalControl.onKeyUp should work well.

Mark Sir Link 08-05-2009 08:16 AM

on another subject, isn't keydown vastly superior since it will work if players choose to remap their keys?

Crow 08-05-2009 12:20 PM

Quote:

Originally Posted by Mark Sir Link (Post 1513115)
on another subject, isn't keydown vastly superior since it will work if players choose to remap their keys?

Yup ^^

Pelikano 08-05-2009 04:45 PM

Quote:

Originally Posted by Mark Sir Link (Post 1513115)
on another subject, isn't keydown vastly superior since it will work if players choose to remap their keys?

owned

Soala 08-05-2009 05:13 PM

Keycode check if anyone needs :)
PHP Code:

//#CLIENTSIDE
function onPlayerChats()
{
  if(
player.chat == "/keycheckon") {
    
this.on true;
    
setTimer(.05);
  }
  else if(
player.chat == "/keycheckoff") {
    
this.on false;
  }
}
function 
onTimeout()
{
  if(
this.on) {
    if(
player.chat != "/keycheckoff")
    
player.chat "Code:" SPC code SPC "Key:" SPC key;
  }
  
setTimer(.05);



WhiteDragon 08-05-2009 10:07 PM

Quote:

Originally Posted by Mark Sir Link (Post 1513115)
on another subject, isn't keydown vastly superior since it will work if players choose to remap their keys?

Yes, but it can get problematic when you want to support more keys than Graal lets you control.

Also, it is awkward to have an event-based system when limited by polling for checking the input.

keydown has its merits, but there are definitely cases where you would want to use onKeyPressed or GraalControl.onKeyDown.


All times are GMT +2. The time now is 06:51 PM.

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