View Single Post
  #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