Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-20-2009, 08:09 PM
Mattehy Mattehy is offline
Developer
Mattehy's Avatar
Join Date: Jul 2009
Posts: 58
Mattehy is on a distinguished road
onKeyPressed()

PHP Code:
function onKeyPressed(code,key)
{
  if (
key == ???) 
Does anyone know the keys(vars) for the arrow keys im making a flute
__________________
Develop 4 Lyf
Reply With Quote
  #2  
Old 08-20-2009, 08:30 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
You could get them with something like this:

PHP Code:
function onKeyPressed(codekey) {
  
player.chat code;

Reply With Quote
  #3  
Old 08-20-2009, 08:31 PM
Mattehy Mattehy is offline
Developer
Mattehy's Avatar
Join Date: Jul 2009
Posts: 58
Mattehy is on a distinguished road
oh good idea xD
__________________
Develop 4 Lyf
Reply With Quote
  #4  
Old 08-21-2009, 04:08 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
you could also use....
PHP Code:
function onKeyPressed(keycodekeyscancode) {
  
player.chat keycode SPC "/" SPC "/" SPC scancode;

to check all params'
__________________
.
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
  #5  
Old 08-21-2009, 05:21 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
PHP Code:
function onKeyPressed() {
  if (
keydown(0-3)) {
    
player.chat "arrow key pressed";
  }

keydown(int) can be used along with onKeyPressed() to detect default key configurations.
Reply With Quote
  #6  
Old 08-21-2009, 05:51 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 DustyPorViva View Post
PHP Code:
function onKeyPressed() {
  if (
keydown(0-3)) {
    
player.chat "arrow key pressed";
  }

keydown(int) can be used along with onKeyPressed() to detect default key configurations.
doesn't give him the code... does it?
Reply With Quote
  #7  
Old 08-21-2009, 05:57 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
Quote:
Originally Posted by Pelikano View Post
doesn't give him the code... does it?
Why would he need the code if he can detect it with the alternative I gave? Not to mention he was already given a script to detect the code... so yeah.
Reply With Quote
  #8  
Old 08-21-2009, 07:42 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by DustyPorViva View Post
PHP Code:
function onKeyPressed() {
  if (
keydown(0-3)) {
    
player.chat "arrow key pressed";
  }

keydown(int) can be used along with onKeyPressed() to detect default key configurations.

That's a bit vague for someone that might not be familiar with loops since they wouldn't realize that they would benefit from using one in this case:

PHP Code:
function onKeyPressed() {
  for (
temp.key 0temp.key 4temp.key++) {
    if (
keydown(key)) {
      
player.chat "directional key pressed";
    }
  }


Stuff like this has been posted before, possibly in multiple threads, people should really use the search function, they would get answers to their questions much faster.


EDIT: It's probably better to say 'directional key pressed' instead of 'arrow key pressed' since that would imply that the script would only trigger when you press an arrow key, when in fact it would trigger whenever you pressed any of the directional keys that you have set in your F3 options.

Last edited by Gambet; 08-21-2009 at 08:02 PM..
Reply With Quote
  #9  
Old 08-21-2009, 09:39 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
Quote:
Originally Posted by Gambet View Post
That's a bit vague for someone that might not be familiar with loops since they wouldn't realize that they would benefit from using one in this case:

PHP Code:
function onKeyPressed() {
  for (
temp.key 0temp.key 4temp.key++) {
    if (
keydown(key)) {
      
player.chat "directional key pressed";
    }
  }


Stuff like this has been posted before, possibly in multiple threads, people should really use the search function, they would get answers to their questions much faster.


EDIT: It's probably better to say 'directional key pressed' instead of 'arrow key pressed' since that would imply that the script would only trigger when you press an arrow key, when in fact it would trigger whenever you pressed any of the directional keys that you have set in your F3 options.
Eh, I was more providing the values he could use(0-3) rather than implying he should loop... which he should.

As for arrows vs directional... probably, but it should always be applied to the customization of the player. If the player chooses to use WASD as their directional keys, this should also apply to whatever GUI's the player is using, so really directional translates into arrow as the player customizes them to basically be such(even if they're regular keys instead of the arrow keys). Developers need to keep that in mind.
Reply With Quote
  #10  
Old 08-21-2009, 09:50 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
It would be better if Stefan would provide a variable for which keys are used for movement/other stuff.

It's silly and redundant to have an event that passes paramaters, only to then have to call another function to see if a key is pressed, but I guess that's Graal.
__________________
Reply With Quote
  #11  
Old 08-21-2009, 10:25 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 cbk1994 View Post
It would be better if Stefan would provide a variable for which keys are used for movement/other stuff.

It's silly and redundant to have an event that passes paramaters, only to then have to call another function to see if a key is pressed, but I guess that's Graal.
I only read that part, but it won't happen
Reply With Quote
  #12  
Old 08-21-2009, 10:42 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
Quote:
Originally Posted by Pelikano View Post
I only read that part, but it won't happen
I only read "Pelikano" on the left side of my screen, then realized the following text wouldn't be worth paying attention to.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #13  
Old 08-22-2009, 01:38 AM
Mattehy Mattehy is offline
Developer
Mattehy's Avatar
Join Date: Jul 2009
Posts: 58
Mattehy is on a distinguished road
Found Out The arrowkeys xD yesterday night its 38-40 xD
__________________
Develop 4 Lyf
Reply With Quote
  #14  
Old 08-22-2009, 03:23 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by mattehy View Post
found out the arrowkeys xd yesterday night its 38-40 xd
37-40 using the first param of onKeyPressed()
0-3 using keydown()
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #15  
Old 08-22-2009, 11:14 AM
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 xXziroXx View Post
I only read "Pelikano" on the left side of my screen, then realized the following text wouldn't be worth paying attention to.
Yet you read and answered to it? aww c'mon use some sense, please.
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 11:48 AM.


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