Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-02-2009, 09:20 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
Keydown

Is there any way to get the keyname
HTML Code:
keyname(int keycode) returns string
^Returns UP, LEFT, DOWN and RIGHT, from when a player is pressing the default keys to move.

from the function 'onKeyDown'
HTML Code:
onKeyDown(keycode, key) 
mainly looking at the keycode, not the key.

Or, to just check if a player is pressing one of the detault keys set on Graals F3 options?
Reply With Quote
  #2  
Old 05-02-2009, 10:12 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Not sure I completely understand what you're trying to do but I suppose you could do something like this:

PHP Code:
//#CLIENTSIDE
function GraalControl.onKeyDown(kcodekstringscode)
{
 
temp.keyList = {{380}, {371}, {402}, {393}}; //Up, Left, Down, Right
 
 
for (0keyList.size(); i++)
  {
   if (
keyList[i][0] == kcode)
    {
     
player.chat keyname(keyList[i][1]);
    }
  }

Reply With Quote
  #3  
Old 05-02-2009, 10:15 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
u missed a param.
PHP Code:
onKeyDown(keycodekeynamescancode
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #4  
Old 05-02-2009, 10:34 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
Quote:
Originally Posted by Deas_Voice View Post
u missed a param.
PHP Code:
onKeyDown(keycodekeynamescancode
You're kidding- haha I love you

Thanks


Only one problem- it doesn't detect the arrow keys for 'I,J,K,L'- any solutions? lol
Reply With Quote
  #5  
Old 05-02-2009, 11:06 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by [email protected] View Post
Only one problem- it doesn't detect the arrow keys for 'I,J,K,L'- any solutions? lol

Again, assuming I'm understanding what you're trying to do, then the solution I posted above should work if you just add to the array. The array I posted will only read the directional keys since I just made a quick model but you can add the keycodes for 'i, j, k, l' and give them the same numbers as the directionals (0, 1, 2, 3), which should return 'Up, Left, Down, Right' or whatever when you press those keys.
Reply With Quote
  #6  
Old 05-02-2009, 11:22 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
Quote:
Originally Posted by Gambet View Post
Again, assuming I'm understanding what you're trying to do, then the solution I posted above should work if you just add to the array. The array I posted will only read the directional keys since I just made a quick model but you can add the keycodes for 'i, j, k, l' and give them the same numbers as the directionals (0, 1, 2, 3), which should return 'Up, Left, Down, Right' or whatever when you press those keys.
You're not understanding- those are not the DEFAULT Graal controls.
Reply With Quote
  #7  
Old 05-02-2009, 11:37 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by [email protected] View Post
You're not understanding- those are not the DEFAULT Graal controls.

Yes they are:

PHP Code:
keydown(int keynumber) - returns if the specified key is pressed (0..10upleftdownrightSADMtabQP

Those are the default keynumbers that correspond to the specified keynames, which is why if you did
player.chat = keyname(0); it would return 'Up' and so forth.
Reply With Quote
  #8  
Old 05-02-2009, 11:50 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
Quote:
Originally Posted by Gambet View Post
Yes they are:

PHP Code:
keydown(int keynumber) - returns if the specified key is pressed (0..10upleftdownrightSADMtabQP

Those are the default keynumbers that correspond to the specified keynames, which is why if you did
player.chat = keyname(0); it would return 'Up' and so forth.
In your method you are specifiying what the keys are. What if I were to edit my DEFAULT arrow keys to something like '1, 2, 3 and 4', your method would still be looking for your basic arrow keys
Reply With Quote
  #9  
Old 05-03-2009, 12:12 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by [email protected] View Post
In your method you are specifiying what the keys are. What if I were to edit my DEFAULT arrow keys to something like '1, 2, 3 and 4', your method would still be looking for your basic arrow keys

Oh, then you could do something like this:

PHP Code:
//#CLIENTSIDE
function GraalControl.onKeyDown(kcodekstringscode)
{
 for (
011i++)
  {
   if (
keydown(i)) 
    {
     
player.chat "The player has pressed the" SPC kstring SPC "key which is the default action for" SPC keyname(i);
    }
  }


EDIT: The default controls have keynumber values that range from 0-10 regardless of what key you assign to perform the action, which is why regardless of what keys you press to move your character, the keynumbers for directionals will always be 0, 1, 2, and 3.

Last edited by Gambet; 05-03-2009 at 12:33 AM..
Reply With Quote
  #10  
Old 05-03-2009, 01:09 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
There is no way to read default key assignments. If there is, it's not been documented.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #11  
Old 05-03-2009, 02:58 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
Quote:
Originally Posted by xXziroXx View Post
There is no way to read default key assignments. If there is, it's not been documented.
Thanks


For some reason the keys 'I,J,K,L' [movement] don't come recognized as movement keys... x-x
Reply With Quote
  #12  
Old 05-03-2009, 03:00 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by [email protected] View Post
Thanks


For some reason the keys 'I,J,K,L' [movement] don't come recognized as movement keys... x-x
keydown(int) detects them perfectly fine.
Reply With Quote
  #13  
Old 05-05-2009, 05:58 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
Quote:
Originally Posted by Crow View Post
keydown(int) detects them perfectly fine.
Oh true. They're not classed as movement keys though.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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