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 08-04-2009, 03:43 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
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
Reply With Quote
  #2  
Old 08-04-2009, 04:07 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
You should probably go for keydown(), the numbers to use with it are the same as the direction numbers of players/npcs (0-3).
Reply With Quote
  #3  
Old 08-04-2009, 04:38 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Appreciate it bro.
Reply With Quote
  #4  
Old 08-04-2009, 05:12 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
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
    
}
  }

Reply With Quote
  #5  
Old 08-04-2009, 06:59 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
If I remember correctly, the onKeyPressed() keycodes are 37, 38, 39 and 40.
__________________
Skyld
Reply With Quote
  #6  
Old 08-04-2009, 07:17 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Skyld View Post
If I remember correctly, the onKeyPressed() keycodes are 37, 38, 39 and 40.

Hmm? The code I posted works just fine.
Reply With Quote
  #7  
Old 08-04-2009, 07:33 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Gambet View Post
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.
__________________
Skyld
Reply With Quote
  #8  
Old 08-04-2009, 07:42 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #9  
Old 08-04-2009, 08:01 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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.
Reply With Quote
  #10  
Old 08-05-2009, 04:47 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
GraalControl.onKeyDown and GraalControl.onKeyUp should work well.
Reply With Quote
  #11  
Old 08-05-2009, 08:16 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
on another subject, isn't keydown vastly superior since it will work if players choose to remap their keys?
Reply With Quote
  #12  
Old 08-05-2009, 12:20 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 Mark Sir Link View Post
on another subject, isn't keydown vastly superior since it will work if players choose to remap their keys?
Yup
Reply With Quote
  #13  
Old 08-05-2009, 04:45 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by Mark Sir Link View Post
on another subject, isn't keydown vastly superior since it will work if players choose to remap their keys?
owned
Reply With Quote
  #14  
Old 08-05-2009, 05:13 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
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);

Reply With Quote
  #15  
Old 08-05-2009, 10:07 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Mark Sir Link View Post
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.
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 08:29 AM.


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