Difference between revisions of "LlGetAndResetTime"

From Second Life Wiki
Jump to navigation Jump to search
m (Undo revision 28526 by Locke Traveler (Talk) affect is emotional, effect is physical)
m (Sync with llGetTime)
 
(17 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{LSL_Function
{{Issues/SVC-3293}}{{LSL_Function
|func_id=84
|func_id=84
|func_sleep=0.0
|func_sleep=0.0
Line 6: Line 6:
|sort=GetAndResetTime
|sort=GetAndResetTime
|return_type=float
|return_type=float
|return_text=time in seconds.
|return_text=that is script time in seconds and then resets the script time to zero.
|func_footnote=Retrieves the time in seconds since since the last script reset (or since the last call to [[llResetTime]]/llGetAndResetTime), then resets the time to zero.
|func_footnote
|spec
|spec=Script time is the amount of time the script has been running since it first started, was most recently reset, or one of the reset functions was called.  It is unaffected by time dilation.
|caveats=*Known to be reset by various events outside user control, such as sim resets. Reliable only for short term timing measurements.
|caveats=
*Effected by [[llGetRegionTimeDilation|time dilation]].
*Script time is the amount of real-world time that the script has been in a running state. It is unaffected by time dilation, but it does not count time while the script is suspended, the user is offline (when in an attachment), the object is in inventory rather than rezzed, etc.
|examples=<pre>
*Script time resets when...
default {
**Script reset (user or [[llResetScript]] or [[llResetOtherScript]])
    state_entry()
**Call to either [[llResetTime]] or [[llGetAndResetTime]]
    {
* Due to (32 bit) floating point number limitations, the accuracy of this function is 1/32sec up to ~3 days, 1/16sec up to ~6 days, etc... doubling each time, e.g. it's only 1 second at ~194 days. Use [[llResetTime]] or [[llGetAndResetTime]] whenever practical to maintain the accuracy you require.
        llResetTime();
|examples=<source lang="lsl2">
    }
default
{
     touch_start(integer num_touch)
     touch_start(integer num_touch)
     {
     {
         float time = llGetAndResetTime(); //This is equivalent to calling llGetTime(), then llResetTime()    
         // This is equivalent to calling llGetTime(), then llResetTime()
         llSay(0,(string)time + " seconds have elapsed since the last touch." );
        float time = llGetAndResetTime();
 
         llSay(0, (string)time + " seconds have elapsed since the last touch or boot-up.");
     }
     }
}
}
</pre>
</source>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llResetTime]]|}}
|also_functions={{LSL DefineRow||[[llResetTime]]|}}
{{LSL DefineRow||[[llGetTime[[|}}
{{LSL DefineRow||[[llGetTime]]|}}
{{LSL DefineRow||[[llGetRegionTimeDilation]]}}
|also
|also
|notes
|cat1=Time
|cat1=Time
|cat2=Script
|cat2=Script

Latest revision as of 11:54, 11 May 2019

Summary

Function: float llGetAndResetTime( );

Returns a float that is script time in seconds and then resets the script time to zero.

Specification

Script time is the amount of time the script has been running since it first started, was most recently reset, or one of the reset functions was called. It is unaffected by time dilation.

Caveats

  • Script time is the amount of real-world time that the script has been in a running state. It is unaffected by time dilation, but it does not count time while the script is suspended, the user is offline (when in an attachment), the object is in inventory rather than rezzed, etc.
  • Script time resets when...
  • Due to (32 bit) floating point number limitations, the accuracy of this function is 1/32sec up to ~3 days, 1/16sec up to ~6 days, etc... doubling each time, e.g. it's only 1 second at ~194 days. Use llResetTime or llGetAndResetTime whenever practical to maintain the accuracy you require.
All Issues ~ Search JIRA for related Bugs

Examples

default
{
    touch_start(integer num_touch)
    {
        // This is equivalent to calling llGetTime(), then llResetTime()
        float time = llGetAndResetTime();

        llSay(0, (string)time + " seconds have elapsed since the last touch or boot-up.");
    }
}

See Also

Functions

•  llResetTime
•  llGetTime
•  llGetRegionTimeDilation

Deep Notes

All Issues

~ Search JIRA for related Issues
   llGetTime doesn't reset on admin requested sim restart

Signature

function float llGetAndResetTime();