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 10-27-2004, 04:36 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
keydown||pressed

Well, I was wondering if there is a way to check if the player presses a specific button down twice..
How would I do this?

Like if they press up once and then press it again they start running etc

thx
__________________
Reply With Quote
  #2  
Old 10-27-2004, 05:09 PM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
Just check for the key and count to see if it were pressed twice, but you'd need to reset it if they didnt press the key again after a certain amount of time.
Reply With Quote
  #3  
Old 10-27-2004, 06:07 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
How would I check to see if they pressed it twice?

Set a flag the first time and do a statement checking if it's already pressed?

I'm also a bit confused on how to check after a period of time, would I use a timeout throughout the script?
__________________
Reply With Quote
  #4  
Old 10-27-2004, 09:20 PM
Slash-P2P Slash-P2P is offline
Banned
Join Date: May 2004
Location: Burning Blade
Posts: 941
Slash-P2P is on a distinguished road
This probably isnt the best way...but...
NPC Code:

//#CLIENTSIDE
if (created || initialized) { // Main block
setstring this.key,a; // Key that can be hit twice [needs different script for arrow keys]
this.time = .3; // Time before the pressed thing expires.
timeout = .05; // Start our loop!
}
if (timeout) { // Self explanitory...
timeout = .05; // Timeout loop
if (this.presstime > 0) { // See how long since you pressed the key
this.presstime -= .05; // Take time out of the variable
} else {
this.presstime = 0; // Make sure we dont have negative time
if (this.pressnumber > 0) this.pressnumber = 0; // Timed out
}
if (keydown2(keycode(#s(this.key)),true)) { // Check if our key is pressed
if (this.keydown == false) { // Only work if the key is not held down
this.keydown = true; // Tell the script the key is held down
if (this.pressnumber == 0) { // Do stuff if number is this blah blah
this.pressnumber = 1; // set the pressed index to 1
this.presstime = this.time; // Time before key pressed resets
} else {
this.pressnumber=0; // Reset press index
this.presstime = 0; // Reset press time
doactions(); // Output
}
}
} else {
this.keydown = false; // Say its not being held down anymore
}
}
function doactions() { // Code for what happens when you hit a key twice.
setplayerprop #c,I hit a key twice! I'm a genious!; // omg kid, you rock!
}



Heres something I thought might help...I don't know if this works, I didn't test it.

Edit:
Tested it and fixed bugs.

Last edited by Slash-P2P; 10-27-2004 at 10:34 PM..
Reply With Quote
  #5  
Old 10-27-2004, 11:07 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Ah!, thanks for the definitions too, you've really helped me !

Thanks again
__________________
Reply With Quote
  #6  
Old 10-28-2004, 12:51 AM
Slash-P2P Slash-P2P is offline
Banned
Join Date: May 2004
Location: Burning Blade
Posts: 941
Slash-P2P is on a distinguished road
Quote:
Originally Posted by xAndrewx
Ah!, thanks for the definitions too, you've really helped me !

Thanks again
If your going to use that for arrow keys, your going to have to change it a lot. You should be able to change it to arrow keys by putting a for loop in there with keydown.
Reply With Quote
  #7  
Old 10-28-2004, 10:25 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Ah, okay

I havn't tested it myself yet, but I will do when I get home, i'll also play with it like you've said.
__________________
Reply With Quote
  #8  
Old 10-28-2004, 07:26 PM
Slash-P2P Slash-P2P is offline
Banned
Join Date: May 2004
Location: Burning Blade
Posts: 941
Slash-P2P is on a distinguished road
Quote:
Originally Posted by xAndrewx
Ah, okay

I havn't tested it myself yet, but I will do when I get home, i'll also play with it like you've said.
I tested it and the script I gave you works.
Reply With Quote
  #9  
Old 10-29-2004, 03:48 AM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to R0bin
Quote:
Originally Posted by Slash-P2P
This probably isnt the best way...but...
NPC Code:

snip code



Heres something I thought might help...I don't know if this works, I didn't test it.

Edit:
Tested it and fixed bugs.
Quote:
Originally Posted by Lance
2) Likewise, don't post whole scripts for people. Post wordy solutions, certainly, but not things that people can just copy & paste into their levels without any effort.
Reply With Quote
  #10  
Old 10-29-2004, 03:23 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
It was a example, I needed help.
__________________
Reply With Quote
  #11  
Old 10-29-2004, 10:52 PM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
it's too bloated for real use anyway (granted that's not the point of the rule)

hey, why is R0bin back?
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #12  
Old 10-29-2004, 11:54 PM
Slash-P2P Slash-P2P is offline
Banned
Join Date: May 2004
Location: Burning Blade
Posts: 941
Slash-P2P is on a distinguished road
Bloated? Yeah I'm sure you could shorten it but I wouldn't use the term 'Bloated'.
Reply With Quote
  #13  
Old 10-30-2004, 11:26 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
I'll be editing it majorly anyway
I'll just say that it's a V 1.0 going through to V 5.0, hopefully.
__________________
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 06:47 AM.


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