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
  #16  
Old 07-30-2004, 08:13 PM
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 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.

The thing is, I am making a menu, and there won't be anything behind it, so no need to use keypressed. I am just having the menu be the whole screen.

Also, I thought that showstats 0; worked quite well.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #17  
Old 07-30-2004, 08:14 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
the variable 'allstats' is the addition of all stats flags, so only 'showstats allstats;' will enable all default status bar stuff again. GoZelda's example was right too, i believe, so 'showstats allstats-1024;' will show everything besides the player.
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #18  
Old 07-30-2004, 08:56 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ugh, one annoyance after another, I replaced the ani, but it still plays the original for a split second when I press arrow keys before it switches to the other animation, just enough time to play that retarded steps.wav once everytime you press an arrow key. :| Is there not a way to make it replace the gani before it gets the chance to start the default gani at all?

NPC Code:

if (created){
replaceani idle,frolic_menu;
replaceani walk,frolic_menu;
}



I appreciate the help. Thank you.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #19  
Old 07-30-2004, 08:59 PM
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
The replaceanis should be done in the created block of a default weapon. You may also want to use the:

weaponorder=

serveroption, which is a comma separated list of weapons the player should load first.

As for the showstats, it's a relatively safe bet that the way you had it first was only showing the last one (512), overriding the others. However, 0 seems more fitting to what you want, unless there is something you still want to preserve.
Reply With Quote
  #20  
Old 07-30-2004, 09:22 PM
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 Lance
The replaceanis should be done in the created block of a default weapon. You may also want to use the:

weaponorder=

serveroption, which is a comma separated list of weapons the player should load first.

As for the showstats, it's a relatively safe bet that the way you had it first was only showing the last one (512), overriding the others. However, 0 seems more fitting to what you want, unless there is something you still want to preserve.
Unfortunately, I am doing this all offline, I don't have a server, therefor server options wouldn't help me much, eh?

The way I had it was doing the exact same as showstats 0; only with alot more commands going through obviously, so to do it with one is much better, thank you again.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #21  
Old 07-31-2004, 04:26 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
Quote:
Originally Posted by Raelyn
Also, I thought that showstats 0; worked quite well.
Well you did say you were trying to hide everything, and thats the way you do it :P
__________________
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
  #22  
Old 07-31-2004, 05:06 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
Well you did say you were trying to hide everything, and thats the way you do it :P
Yes, but Tseng doesn't seem to have realised that problem has already been solved. :|
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #23  
Old 08-08-2004, 01:14 AM
omegaslayer omegaslayer is offline
tKeR
Join Date: May 2004
Posts: 6
omegaslayer is on a distinguished road
This might work?

if (keypressed&&keydown2(keycode(Q),)) {
say2 example;
}
Reply With Quote
  #24  
Old 08-08-2004, 02:16 AM
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
Quote:
Originally Posted by Raelyn
The way I had it was doing the exact same as showstats 0; only with alot more commands going through obviously, so to do it with one is much better, thank you again.
LIES!!

You just didn't notice the inventory, which was the only thing showing since you had showstats 512;.
Quote:
Yes, but Tseng doesn't seem to have realised that problem has already been solved. :|
he was clearing things up for you, since you're posts showed that you didn't quite understand the command entirely


yes, I know this is late, but I didn't read those parts, so blah
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
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 04:09 PM.


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