Graal Forums

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

Cybnext_Design 09-29-2001 11:04 AM

keydown
 
How can i make it so that you cant hold down a key and the action keep going over and over?

Kind of like the sword swing.

You hit 'S' and you swing ur sword, but if you hold it down nothing happens. And you release it and hit it again, and it swings again.

I need this so that i can make something scroll differently, i have tried many ways and here is one of them:

PHP Code:

  //Check for Keydown
    
if (keydown(0)) {
      if (
this.keyd==&& this.fruit<=5) {
        
this.keyd 1;
        
this.fruit++
      }
    }else{
this.keyd 0;}

    if (
keydown(2)) {
      if (
this.keyd==&& this.fruit>=0) {
        
this.keyd 1;
        
this.fruit--;
      }
    }else{
this.keyd 0;} 


Xaviar 09-29-2001 11:34 AM

Re: Re: keydown
 
Quote:

Originally posted by Kaimetsu
Use a different var for each key. An array would work.
Your a genius :D , I woulda stared at that for like half an hour before it woulda popped into my head "Hey! Your using the same variable!"

btedji 10-03-2001 03:15 AM

NPC Code:

if (keydown(0)&& this.fruit<=5) {
this.fruit++;
}

if (keydown(2) && this.fruit>=0) {
this.fruit--;
}




i think this would work too

Cybnext_Design 10-03-2001 08:21 AM

Quote:

Originally posted by btedji
NPC Code:

if (keydown(0)&& this.fruit<=5) {
this.fruit++;
}

if (keydown(2) && this.fruit>=0) {
this.fruit--;
}




i think this would work too

You obviously didn't read my post.

That script would just allow you to hold down the key, and that is exactly what i don't want.

entravial 10-03-2001 09:21 AM

~AlphaFlame~

Using your original method...

//Check for Keydown
if (keydown(0)) {
if (this.keyd1==0 && this.fruit<=5) {
this.keyd1 = 1;
this.fruit++
}
}else{this.keyd1 = 0;}

if (keydown(2)) {
if (this.keyd2==0 && this.fruit>=0) {
this.keyd2 = 1;
this.fruit--;
}
}else{this.keyd2 = 0;}

Cybnext_Design 10-03-2001 09:23 AM

Just to let you guys know, it has already been fixed.

So no need to keep posting answers.

Kaimetsu, can you delete this thread now?

btedji 10-03-2001 07:15 PM

Quote:

Originally posted by Cybnext_Design
Just to let you guys know, it has already been fixed.

So no need to keep posting answers.

Kaimetsu, can you delete this thread now?

this thread doesnt need to be deleted, it is helpful for other people

Shard_IceFire 10-03-2001 08:28 PM

Yeah...well I had the same problem with keydown stuff, but I still don't get how to incorperate arrays like Kaimetsu said...

Shard_IceFire 10-03-2001 08:42 PM

Quote:

setarray this.keys,4;
for(i=0;i!=4;i++){
this.keys[i]=keydown(i);
}
Ok I stared at that script for a minute and couldn't figure it out...what exactly does it do?

Shard_IceFire 10-03-2001 09:02 PM

Umm...ok!


All times are GMT +2. The time now is 03:17 PM.

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