Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Logo's Newbie Scripting Big Guy Scripting Function of THE DAY (https://forums.graalonline.com/forums/showthread.php?t=32304)

Logo 06-26-2002 09:17 AM

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.

Torankusu 06-26-2002 09:53 AM

er.
USE i and numbers.

Logo 06-26-2002 11:37 AM

I don't like i

Torankusu 06-26-2002 03:47 PM

me neither, but I forget what the hell to do .

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

no?

Torankusu 06-27-2002 01:11 AM

Quote:

Originally posted by Kaimetsu
Grim Squeaker:
Almost.
It's actually "for (i=0;i<3;i++)"

Oh. Okay.

Warcaptain 06-27-2002 06:54 AM

for (dothisfirst;anduntillthisistrue;dothis){script before i start over funciton;}

Falcor 06-27-2002 07:14 AM

in c++ you could make it a while loop....
NPC Code:

for(;condition;) {

}



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

amonrabr 06-27-2002 08:03 AM

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

Torankusu 06-27-2002 08:09 AM

Quote:

Originally posted by amonrabr

my tip is to use " this.flag".. sometimes one script can make problems on anothers

with for ?

Torankusu 06-27-2002 07:38 PM

Ohh. I see now.

screen_name 06-28-2002 06:19 AM

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

Dragona2002 06-29-2002 02:42 PM

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

Torankusu 06-29-2002 03:38 PM

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++)

adam 06-30-2002 02:56 AM

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?


All times are GMT +2. The time now is 11:24 AM.

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