Graal Forums

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

dragonslayer440 01-05-2004 09:31 PM

command?
 
what exactly does the for command do??

Loriel 01-05-2004 09:46 PM

for (a; b; c) d;
First executes a; then, until b is false, executes d and c.
for (i = 0; i < 5; i ++) { playerx = i; sleep 0.5; }

DIABLO2099 01-05-2004 11:06 PM

Yeah, the for command is a type of loop.
Using the example Loriel used:
NPC Code:
for (a ; b ; c)


a is usually where the variable initialization takes place.
NPC Code:
i = 0;



b is where the program checks whether or not the requirements to meet the loop are met. If the requirements are met, the loop is peformed and c is done.
NPC Code:
i < 10;



c is the increment.
NPC Code:
i++



Becareful not to place yourself in infinite loops...
NPC Code:
for (i = 0;i < 10;i--)


...such a case.

Hope I did not confuse you more than you were before :(.

GoZelda 01-05-2004 11:11 PM

i=0;
while (i<5){
i++
}

Is the same as
for (i=0;i<5;i++){
}

DIABLO2099 01-05-2004 11:20 PM

Also a do loop is almost the same as a for and a while, just the fact that a do loop does the loop first then checks requirements.

NPC Code:
do {
//actions;
//increment;
} while (condition);



That is the basic format incase anyone who doesn't know, wants to.

GoZelda 01-05-2004 11:28 PM

But unfortunatly a do loop does not yet work on Graal :|

DIABLO2099 01-05-2004 11:39 PM

Quote:

Originally posted by GoZelda
But unfortunatly a do loop does not yet work on Graal :|
New engine, hopefully. x.x

Loriel 01-05-2004 11:52 PM

Pft, nobody uses do {} while (); loops anyway.

wonderboysp2p 01-06-2004 06:37 AM

Quote:

Originally posted by GoZelda
i=0;
while (i<5){
i++
}

Is the same as
for (i=0;i<5;i++){
}


so true ^_^ first time that a saw the debugger changes for loops into whiles i was like "omg wtf??? GRAAL CHANGERD MY SCRIPT!!!!!" but then i looked at it and said.. "oh.. its the same damn thing"


All times are GMT +2. The time now is 02:14 PM.

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