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 01-06-2004, 06:35 AM
wonderboysp2p wonderboysp2p is offline
Registered User
wonderboysp2p's Avatar
Join Date: Sep 2002
Location: -Wonderboy
Posts: 537
wonderboysp2p is on a distinguished road
Send a message via AIM to wonderboysp2p
-keyNOTdown(i)

sorry for being retarded.. i havent been doing any scripting for awhile but oh well!
how would i go about detecting when keys 0-4 were'nt being pushed?


im bored and rescripting movement system and i couldnt think of what to do so he just keeps doing the walk ani unstil i press 'a' XP
__________________

we are the llama FORUms!!!EWQ Ce13d5423f23!! 2e1 @$6tgv3uy65!
Reply With Quote
  #2  
Old 01-06-2004, 06:39 AM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
Well, there are a few ways to do it.

Probably the easiest way is to have a array for it, then run a loop and check the corrisponding key to see if it's pressed, if not, then set the variable to false or whoever you want to keep track of it.
__________________
[signature]insert here[/signature]
Reply With Quote
  #3  
Old 01-06-2004, 06:44 AM
Thought Thought is offline
PipBoy Extraordinaire!
Thought's Avatar
Join Date: Nov 2001
Location: Long Beach, California.
Posts: 692
Thought is on a distinguished road
NPC Code:
!keydown(#)

?
__________________
Rick ([email protected])
#gscript on FreeNode (#gscript Guild, #gscript Information)
Graal User Statistics

I am now using my new account, Rick.
Reply With Quote
  #4  
Old 01-06-2004, 06:44 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally posted by screen_name
Probably the easiest way is to have a array for it, then run a loop and check the corrisponding key to see if it's pressed, if not, then set the variable to false or whoever you want to keep track of it.
Why bother checking? var = keydown(index); works just fine
Reply With Quote
  #5  
Old 01-06-2004, 06:45 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
Rick's got the idea.
Reply With Quote
  #6  
Old 01-06-2004, 06:57 AM
wonderboysp2p wonderboysp2p is offline
Registered User
wonderboysp2p's Avatar
Join Date: Sep 2002
Location: -Wonderboy
Posts: 537
wonderboysp2p is on a distinguished road
Send a message via AIM to wonderboysp2p
else if (!keydown(0)) set ani idle,;


i had this but it screws up the walk ani X_X
__________________

we are the llama FORUms!!!EWQ Ce13d5423f23!! 2e1 @$6tgv3uy65!
Reply With Quote
  #7  
Old 01-06-2004, 07:03 AM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
Quote:
Originally posted by Python523


Why bother checking? var = keydown(index); works just fine
Well hell, I didn't even think of that.
__________________
[signature]insert here[/signature]
Reply With Quote
  #8  
Old 01-06-2004, 07:39 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally posted by wonderboysp2p
else if (!keydown(0)) set ani idle,;


i had this but it screws up the walk ani X_X
well.. that's because your condition is all messed up, and not having brackets doesn't help much either. I would write that same line of code as the following:

If you wanted it to be detected when keydown(0) then:
if (!keydown(0)) {
whatever;
}
else {
setani idle,;
}


If you wanted it to not be detected when keydown(0) then:
if (!keydown(0)) {
setani idle,;
}

And you'd want to make sure with the !keydown that you'd have a timeout or something... I'm not sure if it's the same with keydown considering the fact that I don't use keydown much.
Reply With Quote
  #9  
Old 01-06-2004, 12:47 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
Quote:
Originally posted by Lance
Rick's got the idea.
lol yeah, i thought

"Arrays wtf only Rick makes sense"
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #10  
Old 01-06-2004, 03:13 PM
D1ce2 D1ce2 is offline
Registered User
Join Date: Dec 2003
Location: United Kingdom
Posts: 446
D1ce2 is on a distinguished road
Send a message via AIM to D1ce2 Send a message via Yahoo to D1ce2
Isnt there a quick key in here?
I forgot how it goes but it's like
NPC Code:

if(playerenters)
timeout=0.05;

if(timeout){
if(keypressed){
if(keydown(t),true){
bla;
}
}
timeout=0.05;
}


I forgot maybe it is wrong, o-well I tried.

If you don't want it detecting add a key (!)
like
NPC Code:

if(!bla && !bla2 && !bla3 && !bla4)){
//bla
}


Or as kai would do:
NPC Code:

if(!bla){
if(!bla2){
if(!bla3){
if(!bla4){
//bla stuff
}
}
}
}



As it's easier to read;P
__________________

The time is coming
Reply With Quote
  #11  
Old 01-06-2004, 04:24 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
I thiiiink the original poster's enquire was about a function that would tell him whether any of the keys 0-3 was pressed, so he could unset his walking gani accordingly... so I suppose the most sensible thing to do is
NPC Code:
walking = false;
for (d = 0; d < 4; d ++) {
if (keydown(d)) {
do_walking_stuff();
walking = true;
}
}
tokenize idle walk;
setani #t(walking),;

Reply With Quote
  #12  
Old 01-06-2004, 04:49 PM
D1ce2 D1ce2 is offline
Registered User
Join Date: Dec 2003
Location: United Kingdom
Posts: 446
D1ce2 is on a distinguished road
Send a message via AIM to D1ce2 Send a message via Yahoo to D1ce2
Quote:
Originally posted by Loriel
I thiiiink the original poster's enquire was about a function that would tell him whether any of the keys 0-3 was pressed, so he could unset his walking gani accordingly... so I suppose the most sensible thing to do is
NPC Code:
walking = false;
for (d = 0; d < 4; d ++) {
if (keydown(d)) {
do_walking_stuff();
walking = true;
}
}
tokenize idle walk;
setani #t(walking),;

Either way is fine, though I prefer yours.
__________________

The time is coming
Reply With Quote
  #13  
Old 01-06-2004, 07:40 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
Quote:
Originally posted by D1ce2
Isnt there a quick key in here?
I forgot how it goes but it's like
NPC Code:

if(playerenters)
timeout=0.05;

if(timeout){
if(keypressed){
if(keydown(t),true){
bla;
}
}
timeout=0.05;
}


I forgot maybe it is wrong, o-well I tried.

its
keydown2(keycode(t),false)
Quote:

If you don't want it detecting add a key (!)
like
NPC Code:

if(!bla && !bla2 && !bla3 && !bla4)){
//bla
}


Or as kai would do:
NPC Code:

if(!bla){
if(!bla2){
if(!bla3){
if(!bla4){
//bla stuff
}
}
}
}



As it's easier to read;P
Kai would choose the first, since the checks are related


oman, Loriel's script is crazygonuts, I never thought to use tokenize like that
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #14  
Old 01-06-2004, 10:03 PM
Goboom Goboom is offline
Pixel Monkey
Goboom's Avatar
Join Date: Dec 2001
Location: Michigan
Posts: 1,702
Goboom is on a distinguished road
Send a message via ICQ to Goboom Send a message via AIM to Goboom Send a message via MSN to Goboom Send a message via Yahoo to Goboom
Quote:
Originally posted by Dach

its
keydown2(keycode(t),false)


Kai would choose the first, since the checks are related


oman, Loriel's script is crazygonuts, I never thought to use tokenize like that
Crazygonuts hehe, I don't think many people would even think to do what Loriel did, the thought has never crossed my mind for such a way.
__________________
Reply With Quote
  #15  
Old 01-07-2004, 01:50 AM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
If you bothered to look at the Snippets section of Graal.net (mainly the Elaborate onwall function Loriel posted) you'd already know to do it that way
Reply With Quote
  #16  
Old 01-07-2004, 02:07 AM
Thought Thought is offline
PipBoy Extraordinaire!
Thought's Avatar
Join Date: Nov 2001
Location: Long Beach, California.
Posts: 692
Thought is on a distinguished road
Quote:
Originally posted by Goboom
Crazygonuts hehe, I don't think many people would even think to do what Loriel did, the thought has never crossed my mind for such a way.
I would have, if presented the challenge of scripting a walking system.
__________________
Rick ([email protected])
#gscript on FreeNode (#gscript Guild, #gscript Information)
Graal User Statistics

I am now using my new account, Rick.
Reply With Quote
  #17  
Old 01-07-2004, 03:49 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
I've made 2 or 3 walking systems and hadn't even considered using tokenize, I usually get by with regular arrays. Come to think of it, I don't really remember how I handled setting the animation... ohwell, back to the point, Loriel has got some wack skills in scripting
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #18  
Old 01-07-2004, 04:13 AM
Goboom Goboom is offline
Pixel Monkey
Goboom's Avatar
Join Date: Dec 2001
Location: Michigan
Posts: 1,702
Goboom is on a distinguished road
Send a message via ICQ to Goboom Send a message via AIM to Goboom Send a message via MSN to Goboom Send a message via Yahoo to Goboom
Quote:
Originally posted by Thought

I would have, if presented the challenge of scripting a walking system.
I said many people you happen to be one of the few. :P
__________________
Reply With Quote
  #19  
Old 01-07-2004, 04:21 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Re-Scripting the player is a great exercise.

Difficult. But I don't think anybody expects it to be perfect.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #20  
Old 01-07-2004, 04:50 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
I wish people wouldn't make such wild guesses about how I'd do something.
__________________
Reply With Quote
  #21  
Old 01-07-2004, 10:56 AM
D1ce2 D1ce2 is offline
Registered User
Join Date: Dec 2003
Location: United Kingdom
Posts: 446
D1ce2 is on a distinguished road
Send a message via AIM to D1ce2 Send a message via Yahoo to D1ce2
Quote:
Originally posted by Kaimetsu
I wish people wouldn't make such wild guesses about how I'd do something.
Your back.
__________________

The time is coming
Reply With Quote
  #22  
Old 01-07-2004, 12:07 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by D1ce2
Your back.
Check the sig, man. I'm only here because I'm in a debate about the new supermods, over in the main forum. I only commented here because I was mentioned.
__________________
Reply With Quote
  #23  
Old 01-07-2004, 12:26 PM
D1ce2 D1ce2 is offline
Registered User
Join Date: Dec 2003
Location: United Kingdom
Posts: 446
D1ce2 is on a distinguished road
Send a message via AIM to D1ce2 Send a message via Yahoo to D1ce2
Quote:
Originally posted by Kaimetsu


Check the sig, man. I'm only here because I'm in a debate about the new supermods, over in the main forum. I only commented here because I was mentioned.
*Cough* by me
Anyways, you should come back your highly missed. Eitherway i've got nothing else to say
__________________

The time is coming
Reply With Quote
  #24  
Old 01-07-2004, 02:30 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
Quote:
Originally posted by Kaimetsu
I wish people wouldn't make such wild guesses about how I'd do something.
I think they think you think it should be done like that because of the KI-SGI or stuff.
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #25  
Old 01-07-2004, 03:32 PM
D1ce2 D1ce2 is offline
Registered User
Join Date: Dec 2003
Location: United Kingdom
Posts: 446
D1ce2 is on a distinguished road
Send a message via AIM to D1ce2 Send a message via Yahoo to D1ce2
Quote:
Originally posted by GoZelda

I think they think you think it should be done like that because of the KI-SGI or stuff.
For once your correct.
__________________

The time is coming
Reply With Quote
  #26  
Old 01-07-2004, 03:58 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
Quote:
Originally posted by GoZelda

I think they think you think
it should be done like that because of the KI-SGI or stuff.
Ow, so many thinks.
__________________
"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
  #27  
Old 01-07-2004, 04:50 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by GoZelda
I think they think you think it should be done like that because of the KI-SGI or stuff.
KSI-GS

I'm sure you're right, but they've misinterpreted the document. I wouldn't script it in any of the ways presented thus far.
__________________
Reply With Quote
  #28  
Old 01-07-2004, 04:56 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
Quote:
Originally posted by Kaimetsu
KSI-GS
Atleast i had the right letter -_-
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #29  
Old 01-07-2004, 05:00 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
I wasn't dissin' you, I just wanted to make sure people knew what we were talking about.

It's interesting to see that KSI-GS found its way into the Classic tab requirements. I would never have agreed with that decision, and I doubt that the GST are enforcing it (heck, one of the members breaks almost every rule in there).
__________________
Reply With Quote
  #30  
Old 01-07-2004, 05:11 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
Quote:
Originally posted by Kaimetsu
I wasn't dissin' you, I just wanted to make sure people knew what we were talking about.
Nor did i thought that :o
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #31  
Old 01-08-2004, 01:43 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
hehe another scripting thread gone awry
__________________
Reply With Quote
  #32  
Old 01-08-2004, 03:05 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
NPC Code:

if (created) timeout=.05;
if (timeout) {
if (keydown(#)) {
// move stuff
}elseif (keydown(#)) {
// move stuff
}elseif (keydown(#)) {
// move stuff
}elseif (keydown(#)) {
// move stuff
}else{
// idle stuff
}
timeout=.05;
}


Use elseifs, they're useful
__________________
Reply With Quote
  #33  
Old 01-08-2004, 03:28 AM
Thought Thought is offline
PipBoy Extraordinaire!
Thought's Avatar
Join Date: Nov 2001
Location: Long Beach, California.
Posts: 692
Thought is on a distinguished road
Quote:
Originally posted by ZeLpH_MyStiK
NPC Code:

if (created) timeout=.05;
if (timeout) {
if (keydown(#)) {
// move stuff
}elseif (keydown(#)) {
// move stuff
}elseif (keydown(#)) {
// move stuff
}elseif (keydown(#)) {
// move stuff
}else{
// idle stuff
}
timeout=.05;
}


Use elseifs, they're useful
WRONG.

Think about it, what do you do to run diagonally? You press two arrow keys.
__________________
Rick ([email protected])
#gscript on FreeNode (#gscript Guild, #gscript Information)
Graal User Statistics

I am now using my new account, Rick.
Reply With Quote
  #34  
Old 01-08-2004, 02:34 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Eh, Rick? Your keyboard lacks diagonal arrow keys?
Reply With Quote
  #35  
Old 01-08-2004, 03:08 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally posted by Loriel
Eh, Rick? Your keyboard lacks diagonal arrow keys?
Your keyboard has diagnol arrow keys?
Reply With Quote
  #36  
Old 01-08-2004, 08:31 PM
Thought Thought is offline
PipBoy Extraordinaire!
Thought's Avatar
Join Date: Nov 2001
Location: Long Beach, California.
Posts: 692
Thought is on a distinguished road
He's probably referring to the number pad, eg keys 7, 9, 1 & 3.
__________________
Rick ([email protected])
#gscript on FreeNode (#gscript Guild, #gscript Information)
Graal User Statistics

I am now using my new account, Rick.
Reply With Quote
  #37  
Old 01-08-2004, 08:42 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
Laptop...

Oh sure elseifs are useful but not in this case. Unless you use if (keydown(x)&&keydown(y)){}
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #38  
Old 01-09-2004, 04:45 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by GoZelda
Laptop...

Oh sure elseifs are useful but not in this case. Unless you use if (keydown(x)&&keydown(y)){}
Or assume mutual exclusivity on the opposing arrow keys.
__________________
Reply With Quote
  #39  
Old 01-14-2004, 11:00 AM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
I might be a little late in asking this, but how exactly Loriel's tokenize convention more efficient?

it would seem to me that requesting a string to be searched through and broken down and then assigned to 2 seperate parts of an array wouldnt be as efficient at all.

if (walking == 0)
setani idle;
else
setani walk;

what is less efficient about the old way? It does one check.
even if you wanted to be crafty why not..

setstring blah,idle,walk;
setani #I(blah,walking);

although in terms of efficiency it seems equivilent to me. ::shrugs::
The tokenize idea is crazy and unique, but please explain why it is better.
__________________
Reply With Quote
  #40  
Old 01-14-2004, 07:01 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Certainly is not more efficient, but I deem it more readable or compact, especially with constructions like this
NPC Code:
  if (static == false && playerfreezetime <= 0) {
setstring this.temp,"idle sit walk carry swim","carrystill carrysit carry carryrun","grab push pull","attack","hurt dead";
tokenize #I(this.temp,this.mode);
setani #t(this.submode),;
setstring this.temp,;
}

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:27 PM.


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