A B C D E F G I J K L M N O R S T U V W

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.

 

Credit to: Lslwiki.net (not working) with changes made for brevity and clarity.