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 07-30-2004, 07:09 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Keydown?

I am trying to get keydown to work and it doesn't seem to be working. Does anyone know what I may be doing wrong? I've got:

if (keydown(Q)){
say2 example;
}

I have tried it several ways, and it just simply doesn't seem to work. Any ideas?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #2  
Old 07-30-2004, 07:15 AM
WanDaMan WanDaMan is offline
Master Tux
WanDaMan's Avatar
Join Date: Aug 2002
Location: England, United Kingdom
Posts: 5,571
WanDaMan is a jewel in the roughWanDaMan is a jewel in the rough
Send a message via MSN to WanDaMan
You can't just have keydown as an event. Either use in a timeout or use keypressed (best).

Also, I don't believe that keydown(Q) will work, you'll have to use numeric indexes, I forgot what they are, but I believe Q is 9?
__________________
V$:CONFL16T
Reply With Quote
  #3  
Old 07-30-2004, 08:11 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Keypressed? I don't believe I've seen this used. Could you elaborate?
As for Q being 9, I see that now that you say that, I missunderstood the description before. Thank you.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #4  
Old 07-30-2004, 08:15 AM
Silver Knight Silver Knight is offline
The Ice Cream Social
Silver Knight's Avatar
Join Date: Jun 2001
Location: SoCal
Posts: 541
Silver Knight is on a distinguished road
Send a message via AIM to Silver Knight
Yes, you'll want to use keypressed.
From commands.rtf:
keydown(key) "the specified key is pressed (0..10: up,left,down,right,S,A,D,M,tab,Q,P)"
So, yes, Q would be 9.

If you want to use other letters not specified in the above info, you would use keydown2.
The syntax for keydown2 is similar, keydown2(keycode,ignorecase);
So, with that, and using the keycode() thing, you can do things like:
NPC Code:

if (keypressed) {
if (keydown2(keycode(x),true)) {
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,Stuff,;
}
}



In that code, it would check to see if a key was pressed (keypressed), then would check in the x button was pressed (keydown2(keycode(x),true)) and would ignore the case, so X would work as well.
If all that was true, it would do the triggeraction.
__________________
Reply With Quote
  #5  
Old 07-30-2004, 08:19 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ahh, I see, very awesome, thank you.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #6  
Old 07-30-2004, 09:06 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Silver Knight
Yes, you'll want to use keypressed.
From commands.rtf:
keydown(key) "the specified key is pressed (0..10: up,left,down,right,S,A,D,M,tab,Q,P)"
So, yes, Q would be 9.

If you want to use other letters not specified in the above info, you would use keydown2.
The syntax for keydown2 is similar, keydown2(keycode,ignorecase);
So, with that, and using the keycode() thing, you can do things like:
NPC Code:

if (keypressed) {
if (keydown2(keycode(x),true)) {
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,Stuff,;
}
}



In that code, it would check to see if a key was pressed (keypressed), then would check in the x button was pressed (keydown2(keycode(x),true)) and would ignore the case, so X would work as well.
If all that was true, it would do the triggeraction.
I will note that keydown2 is good for checking specific keys, and keydown is good for if you want to check the keys set in graal options so regardless of what the person has set for the q-menu (maybe a joystick button), the script will work the way you want.
Reply With Quote
  #7  
Old 07-30-2004, 09:21 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ok, I've gotten it working, but I have a question while not keydown related so much as it's related to the same script.

I'm trying to remove all default graal functions, such as, the default GUI, player, animations, sounds etc and I have managed to get rid of everything thus far except sound using the following.

NPC Code:

if (created){
disableselectweapons;
showstats 1;
showstats 2;
showstats 4;
showstats 8;
showstats 16;
showstats 32;
showstats 64;
showstats 128;
showstats 256;
showstats 512;
}



Is this the most effecient way to do this, I'm just worried that however they are not showing, that they are still being calculated unnessesarily? Also, I am trying to get rid of the sounds of walking/swords etc. any suggestion on how to achieve this? I tried:

NPC Code:

if (keypressed) {
if (keydown(0)) {
stopsound steps.wav;
}
}



However it doesn't do the trick...

Thank you again.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #8  
Old 07-30-2004, 10:11 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Raelyn
Ok, I've gotten it working, but I have a question while not keydown related so much as it's related to the same script.

I'm trying to remove all default graal functions, such as, the default GUI, player, animations, sounds etc and I have managed to get rid of everything thus far except sound using the following.

NPC Code:

if (created){
disableselectweapons;
showstats 1;
showstats 2;
showstats 4;
showstats 8;
showstats 16;
showstats 32;
showstats 64;
showstats 128;
showstats 256;
showstats 512;
}

You can combine the showstats:

NPC Code:
showstats 1+2+4+8+16+32+64+128+256+512;



Quote:
Is this the most effecient way to do this, I'm just worried that however they are not showing, that they are still being calculated unnessesarily?
I'd hope not.

Quote:
Also, I am trying to get rid of the sounds of walking/swords etc. any suggestion on how to achieve this? I tried:

NPC Code:

if (keypressed) {
if (keydown(0)) {
stopsound steps.wav;
}
}



However it doesn't do the trick...
This is where you make your own ganis and use replaceani defaultaniname,newaniname;
Reply With Quote
  #9  
Old 07-30-2004, 10:24 AM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
Just wanted to say, thanks for not being a complete jerk to him like some people would to others
__________________
Reply With Quote
  #10  
Old 07-30-2004, 10:35 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ahh, so the sound is in relation to the gani and I simply need to replace the gani? I was hoping to have it not process a gani whatsoever, but I suppose replacing with a single frame gani that does nothing would fix the problem? I am sort of putting together a menu, so a gani for it is pointless, but would a comepletely blank, single frame gani be the best solution?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #11  
Old 07-30-2004, 10:39 AM
Silver Knight Silver Knight is offline
The Ice Cream Social
Silver Knight's Avatar
Join Date: Jun 2001
Location: SoCal
Posts: 541
Silver Knight is on a distinguished road
Send a message via AIM to Silver Knight
I assume you mean to use the arrow keys in the menu to move, and you don't want the walk gani to commence, am I correct?
If that is the case, you should look into the commands disabledefmovement & enabledefmovement, or so.
These commands will disable movement and enable it, respectively.
It would be useful if you wanted to be able to use the arrow keys in the menu to select things, yet the player would not move and the gani would not play, and thus no walking sound.
__________________
Reply With Quote
  #12  
Old 07-30-2004, 10:43 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Actually, I don't want anything on the screen at all, what I am making uses a single level of all black tiles, no GUI, so character on screen, or anything. It's all just going to consist of a single large menu. There isn't really going to be any movement to disable or re-enable.

Edit:

Quote:
Originally Posted by Lance
You can combine the showstats:

NPC Code:
showstats 1+2+4+8+16+32+64+128+256+512;

Tried this and it was a no go.
__________________
*Don't let the door hit you on the way out.*

Last edited by Raelyn; 07-30-2004 at 10:54 AM..
Reply With Quote
  #13  
Old 07-30-2004, 11:42 AM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
Then dont you want...
NPC Code:

showstats 0;


The showstas command is using whats called a bit field to set lots of options at the same time. Simply sum up the numbers of the gui bits you do want to be seen, and then use showstats with that number.
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #14  
Old 07-30-2004, 11:49 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Polo
Then dont you want...
NPC Code:

showstats 0;


The showstas command is using whats called a bit field to set lots of options at the same time. Simply sum up the numbers of the gui bits you do want to be seen, and then use showstats with that number.
Nice. That's great, cleaned up very well.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #15  
Old 07-30-2004, 12:48 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Mh, you could've used keypressed too.

NPC Code:

if (keypressed){
if (strequals(#p(1), q)){
//menu code here
}
}


and for the showstats, if you have so many you might want to consider using.

NPC Code:

showstats allstats-whatever you don't want // Not sure if 'allstats' is correct, but it was something similiar.

__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
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 12:41 PM.


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