Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-26-2003, 10:45 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
Explaination of for

Well, it seemed to me that some people are very unfamiliar with for.

This is what for actually is:
NPC Code:

i = 0;
while (i<50){
i++;
)



So, for works like this:

Quote:
First, there's the "statement". This is, i = 0;.
for (i=0; ----){}
then, comes a "test".
i<50;
for (i=0;i<50){}
and then an "operation"
for (i=0;i<50;i++){}
So, i becomes zero. As long as i is less then 50, 1 will be added to i, until it becomes 50 (or more).
Note: never use

NPC Code:

for (i=0;i<1;i--){}


if you don't want an uber-lagged level with an infinite for-loop.

So, once more:

Quote:
I becomes equilevant to zero. As long as i is less then 50, then there's added one to i.
Ofcourse, you can add much more to a loop.

NPC Code:

for (i=17;i>0;i--){}


for example. I hope you see all possibilities of i. Here's a nice example:

NPC Code:

if (timeout||playerenters){
this.savex=0;
for (i=1;i<64;i++){
showpoly 2,{this.savex,32,i,32};
this.savex=i;
sleep 0.05;
}
timeout = 0.05;
}

__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
 


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 10:34 PM.


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