Don't click here unless you want to be banned.

LSL Wiki : while

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ec2-204-236-235-245.compute-1.amazonaws.com

while Loops


The statements in a while loop are executed over and over while a condition is met.

Format

while (condition) 
{
	statements
}

Note that if the condition is false initially, the statements will never be executed.

Example

This code will wait until it is at least 3600 seconds past the start of the SL day. ...Mostly. See the page on llGetTimeOfDay.

integer bDone = FALSE;

while (!bDone)
{
    if (llGetTimeOfDay() > 3600)
    {
        bDone = TRUE;
    }
    else
    {
        llSleep(500);
    }
}
llSay( 0, "Good morning!" );

The following would behave the same as the above loop.

while( llGetTimeOfDay() < 3600 )
{
    llSleep(500);
}
llSay( 0, "Good morning!" );

Note: Because of the way LSL parser works (more details: http://w-hat.com/stackdepth), conditions in LSL are evaluated left to right, instead of right to left as in most programming languages. Check example on condition page.


FlowControl | do-while | if-else
There is no comment on this page. [Display comments/form]