Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   for loops (https://forums.graalonline.com/forums/showthread.php?t=15160)

btedji 10-22-2001 03:22 AM

for loops
 
can you make a for loop that will accept more than one command during each loop?

KJS 10-22-2001 03:24 AM

Re: for loops
 
Quote:

Originally posted by btedji
can you make a for loop that will accept more than one command during each loop?
yes do it like this

for(this.i=0;this.i<=10;this.i++;){
//coding
}

or something like this

this.i=0;
while(this.i<=10){
this.i++;
//coding
}

dragoonvenganc 10-22-2001 09:32 AM

yep.. but while is a while loop not a for loop..

My favorite nested for loops :)

KJS 10-22-2001 09:38 AM

Quote:

Originally posted by dragoonvenganc
yep.. but while is a while loop not a for loop..

My favorite nested for loops :)

ok first of all I was just giving him an example on how to do that...

and anyways for loops turn into while loops when you execute it (press f6 and look at the coding it turns for loops into while loops)

dragoonvenganc 10-22-2001 10:27 AM

No If i must i will open my computer programming book

I dont care what graal says.

For loops incrment till the number value is unture.

While loops do {} while () that is true..

for has to be a number..

U use For if u know how many times u want to loop and for numbers

While does stuff till it changes

I know u were giveing an example

KJS 10-22-2001 12:12 PM

Quote:

Originally posted by dragoonvenganc
No If i must i will open my computer programming book

I dont care what graal says.

For loops incrment till the number value is unture.

While loops do {} while () that is true..

for has to be a number..

U use For if u know how many times u want to loop and for numbers

While does stuff till it changes

I know u were giveing an example

ok I already know this...

but I was first giving an example of different ways of doing the loop...

and second graal converts for loops into while loops when it runs the coding...

that is all I said...

i know while loops can have other things then numbers and for loops only can have numbers...

but I was saying that graal converts for loops into while loops when you run it... (well at lest in the debug screen)

dragoonvenganc 10-22-2001 08:26 PM

Ok but i speak in programming terms i do not know how the graal engine does stuff

PresShinP2P 10-22-2001 11:46 PM

for (i=1;i>0;i++){
for(j=1;i<0;j++){
}}

ahh yes the nested for loop is a mans best friend

JeffTL 10-23-2001 12:34 AM

The best loops are made with timeout=.05.


ADDED FOR ESSENTIAL GEEKINESS:

A timeloop in Graal is basically a self-calling function. I'm trying to get a function to call itself in graal...doesn't work too good. So I'll pass function Moby through function ****, having them call each other, whilst having function melville, place that in functions moby and ****...Melville triggered once, lagged a lot...timeout works better. Later I'll try it with a sleep command.

btedji 10-23-2001 03:14 AM

you do not need timeouts for loops unless you want them to run more than one time in a row, and i dont think doing for(#,#,#){commands;} will work because the for loop looks for ; in the loop and that is where the loop ends and starts with the next number, but i may be mistaken

dragoonvenganc 10-23-2001 09:47 AM

Yes finally some one understands nested for loops.. man.. no one said anything about that..

It is great for doing things like hitobjects and so on.. taking a 17kb weapon and make it to a 2kb weapon is great just becuase of for loops..

and yes for loops are like this

for(variable=#;variable logicstatment #;variable incrementation){Commands}

first part sets the variable to that value when it starts, logic statments are like = < > , I++ adds 1 to i each time

Hey shin wanna job as scripter on server.
Anyone that knows what a nested for is is cool in my book lol

Falcor 10-23-2001 09:53 AM

i wish we could do stuff like..

for(i=0,j=0;i<100,j<100;i++,j++;) {commands;}

dragoonvenganc 10-23-2001 10:38 AM

Why.. j and i would always be =.. what is the use

KJS 10-23-2001 11:05 AM

Quote:

Originally posted by dragoonvenganc
Why.. j and i would always be =.. what is the use
well I think he is meaning like 1 adds up then the next..
well kinda of like

for(this.x=0;this.x<=10;this.x++) for(this.y=0;this.y<=10;this.y++){
//coding
}

I think he means like so it would run it like that

dragoonvenganc 10-23-2001 10:17 PM

I have not tried can u do 2 conditon staments like x>0&&y<45
if so then u could do that ...just increment y inside the loop


All times are GMT +2. The time now is 06:36 PM.

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