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 06-26-2002, 09:17 AM
Logo Logo is offline
Banned
Join Date: Nov 2001
Posts: 377
Logo is on a distinguished road
Send a message via AIM to Logo
Logo's Newbie Scripting Big Guy Scripting Function of THE DAY

The "for" command is a very good command. Used for indexes, etc., or hell,it can be used for just about anything.

Here is what the basic for command looks like:

NPC Code:

for (var=integer;var<othervaroninteger;var++) {}



The first little section thing (for (HEREPEOPLE;.;.) {}) does what it says there, then for the middle section, every time it performs what is inside the {} brackets, it checks to see if var is less than, equal to, or more than the other integer or variable. If it is, it does what is in the brackets, then does what is in the 3rd section/column. I know it's a sloppy explanation, but it is understandable.
Reply With Quote
  #2  
Old 06-26-2002, 09:53 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
er.
USE i and numbers.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #3  
Old 06-26-2002, 11:37 AM
Logo Logo is offline
Banned
Join Date: Nov 2001
Posts: 377
Logo is on a distinguished road
Send a message via AIM to Logo
I don't like i
Reply With Quote
  #4  
Old 06-26-2002, 03:47 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
me neither, but I forget what the hell to do .

for (i=3;i=<3;i++)

no?
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #5  
Old 06-27-2002, 01:11 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by Kaimetsu
Grim Squeaker:
Almost.
It's actually "for (i=0;i<3;i++)"
Oh. Okay.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #6  
Old 06-27-2002, 06:54 AM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
for (dothisfirst;anduntillthisistrue;dothis){script before i start over funciton;}
Reply With Quote
  #7  
Old 06-27-2002, 07:14 AM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
in c++ you could make it a while loop....
NPC Code:

for(;condition;) {

}



never tried it in graal, hypothetically, it should work.
__________________

subliminal message: 1+1=3
Reply With Quote
  #8  
Old 06-27-2002, 08:03 AM
amonrabr amonrabr is offline
Scripter
Join Date: Nov 2001
Location: Brazil
Posts: 374
amonrabr is on a distinguished road
Quote:
Originally posted by Torankusu
er.
USE i and numbers.
my tip is to use " this.flag".. sometimes one script can make problems on anothers
Reply With Quote
  #9  
Old 06-27-2002, 08:09 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by amonrabr

my tip is to use " this.flag".. sometimes one script can make problems on anothers
with for ?
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #10  
Old 06-27-2002, 07:38 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Ohh. I see now.
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #11  
Old 06-28-2002, 06:19 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 Kaimetsu
Grim Squeaker:
Almost.
It's actually "for (i=0;i<3;i++)"
lol, not necessarily


NPC Code:

for (this.i=5;this.i>=0;this.i--) {
if (this.i==-1) {
message KABOOM!!!!;
} elsif (this.i>=0) {
message #v(this.i);
}
sleep 1;
}
-----------------------------------------
message Your target is 5, say GO to begin rolling;
if (playerchats && strequals(#c,GO)) {
go();
}
function go() {
for (this.i=int(random(0,11));this.i!=5;this.i=int(ran dom(0,11))) {
message Darn, you were only #v(abs(5-this.i)) away;
sleep 1;
}
}



etc, etc

can be used for lots of things
__________________
[signature]insert here[/signature]
Reply With Quote
  #12  
Old 06-29-2002, 02:42 PM
Dragona2002 Dragona2002 is offline
Registered User
Join Date: May 2002
Location: The Netherlands
Posts: 105
Dragona2002 is on a distinguished road
Send a message via AIM to Dragona2002 Send a message via Yahoo to Dragona2002
X.x can you guys help me i stil dont get th ´´i´´ things etc...
defenetly not with much numbers next to it X.x
__________________

Quote:
The Dark Nemesis begins.......
Reply With Quote
  #13  
Old 06-29-2002, 03:38 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally posted by Dragona2002
X.x can you guys help me i stil dont get th ´´i´´ things etc...
defenetly not with much numbers next to it X.x
well, okay.

for (i=0; --- it sets i to 0.
i<10; --- checks to see if i is less than 10. if it is...:
i++) ------ adds 1 to i.

with "this.i" flags:
for (this.i=0;
this.i<10;
this.i++)


The correct formats would be:
for (i=0;i<10;i++)
for this.i=0;this.i<10;this.i++)
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #14  
Old 06-30-2002, 02:56 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
Quote:
Originally posted by Dragona2002
X.x can you guys help me i stil dont get th ´´i´´ things etc...
defenetly not with much numbers next to it X.x

I means index becouse mostly that's what people use it for. indexes.


i is just like any other variable. It has no special meaning in itself. Your not required to use i. You can use x or y or j or k or this.xygsyokjos or cat or dog or


Well you get the point?
__________________
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
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:44 PM.


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