Difference between revisions of "LlSleep"

From Second Life Wiki
Jump to navigation Jump to search
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|func_id=108|func_sleep=0.0|func_energy=0.0
|func_id=108|func_sleep=0.0|func_energy=0.0
|func=llSleep|p1_type=float|p1_name=sec
|func=llSleep|p1_type=float|p1_name=sec|p1_desc=seconds to sleep
|func_footnote
|func_footnote
|func_desc=Put script to sleep for '''sec''' seconds.
|func_desc=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.
 
|return_text
|return_text
|spec
|spec
|caveats
|caveats
|constants
|constants
|examples
|examples=<source lang="lsl2">
default
{
    state_entry()
    {
        llSay(0, "I going to take a nap for 5 seconds.");
        llSleep(5.0);
        llSay(0, "I feel so refreshed!");
    }
}
</source>
<source lang="lsl2">
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
        }
    }
}
</source>
|helpers
|helpers
|also_functions
|also_functions={{LSL DefineRow||[[llSetTimerEvent]]}}
|also_events
|also_events={{LSL DefineRow||[[timer]]}}
|also_tests
|also_tests
|also_articles
|also_articles
Line 18: Line 56:
|negative_index
|negative_index
|sort=Sleep
|sort=Sleep
|cat1
|cat1=Script
|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 15:23, 21 January 2023

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

Search JIRA for related Issues

Signature

function void llSleep( float sec );

Haiku

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