Difference between revisions of "LlSleep"

From Second Life Wiki
Jump to navigation Jump to search
m (Replaced <source> with <syntaxhighlight>)
 
Line 13: Line 13:
|caveats
|caveats
|constants
|constants
|examples=<source lang="lsl2">
|examples=<syntaxhighlight lang="lsl2">
default
default
{
{
Line 23: Line 23:
     }
     }
}
}
</source>
</syntaxhighlight>
<source lang="lsl2">
<syntaxhighlight lang="lsl2">
default
default
{
{
Line 46: Line 46:
     }
     }
}
}
</source>
</syntaxhighlight>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llSetTimerEvent]]}}
|also_functions={{LSL DefineRow||[[llSetTimerEvent]]}}
Line 57: Line 57:
|sort=Sleep
|sort=Sleep
|cat1=Script
|cat1=Script
|haiku={{Haiku|Clouds drift,streams flow on.|Yet in here, time holds its breath.|The mind disconnects.}}
|haiku={{Haiku|Clouds drift, streams flow on.|Yet in here, time holds its breath.|The mind disconnects.}}
|cat2
|cat2
|cat3
|cat3
|cat4
|cat4
}}
}}

Latest revision as of 08:26, 22 September 2024

Summary

Function: llSleep( float sec );

Puts the script to sleep for sec seconds. The script will not do anything during this time.

The script will sleep at least until the next server-frame, which happen every (1/45 = ~0.02222) seconds under normal conditions.

If sec is zero or less, the script will not sleep at all.

• float sec seconds to sleep

Examples

default
{
    state_entry()
    {
        llSay(0, "I going to take a nap for 5 seconds.");
        llSleep(5.0);
        llSay(0, "I feel so refreshed!");
    }
}
default
{
    state_entry()
    {
        llOwnerSay("Time between sleeps:");

        integer loops = 10;
        float last_time = 0.0;

        llResetTime();
        llSleep(0.02);

        while (--loops)
        {
            float time = llGetTime();
            llOwnerSay((string)(time - last_time));
            last_time = time;
            llSleep(0.0); // Try a value above zero
        }
    }
}

See Also

Events

•  timer

Functions

•  llSetTimerEvent

Deep Notes

Signature

function void llSleep( float sec );

Haiku

Clouds drift, streams flow on.
Yet in here, time holds its breath.
The mind disconnects.