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-05-2004, 09:31 PM
dragonslayer440 dragonslayer440 is offline
Registered User
Join Date: Dec 2003
Posts: 1
dragonslayer440 is on a distinguished road
Send a message via AIM to dragonslayer440
command?

what exactly does the for command do??
Reply With Quote
  #2  
Old 01-05-2004, 09:46 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
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; }
Reply With Quote
  #3  
Old 01-05-2004, 11:06 PM
DIABLO2099 DIABLO2099 is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 290
DIABLO2099 is on a distinguished road
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 .
__________________
-Former UnholyNation Server Manager.

Call me Xecutor.
Reply With Quote
  #4  
Old 01-05-2004, 11: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
i=0;
while (i<5){
i++
}

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

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #5  
Old 01-05-2004, 11:20 PM
DIABLO2099 DIABLO2099 is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 290
DIABLO2099 is on a distinguished road
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.
__________________
-Former UnholyNation Server Manager.

Call me Xecutor.
Reply With Quote
  #6  
Old 01-05-2004, 11:28 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
But unfortunatly a do loop does not yet work on Graal :|
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #7  
Old 01-05-2004, 11:39 PM
DIABLO2099 DIABLO2099 is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 290
DIABLO2099 is on a distinguished road
Quote:
Originally posted by GoZelda
But unfortunatly a do loop does not yet work on Graal :|
New engine, hopefully. x.x
__________________
-Former UnholyNation Server Manager.

Call me Xecutor.
Reply With Quote
  #8  
Old 01-05-2004, 11:52 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
Pft, nobody uses do {} while (); loops anyway.
Reply With Quote
  #9  
Old 01-06-2004, 06:37 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
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"
__________________

we are the llama FORUms!!!EWQ Ce13d5423f23!! 2e1 @$6tgv3uy65!
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 04:57 PM.


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