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

LSL Wiki : llSetTimerEvent

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl836.us.archive.org
llSetTimerEvent(float sec)

Sets the timer event to be triggered every sec seconds. Passing 0.0 (or just 0) stops further timer events.

The timer persists over state changes, but gets removed when the script is reset.
It should be noted that, perhaps due to event delay, you can't get more than 25 timer events per second. And so setting the interval lower than 0.04 has no real effect, except filling up the event queue.


default
{
    state_entry()
    {
        llSetTimerEvent(300); // five minutes: 5*60--no need to make LSL do this simple calculation
    }

    timer()
    {
        llOwnerSay("timeout");
//      llSetTimerEvent(0);   (to stop the timer)
    }
}

Calling llSetTimerEvent replaces any existing timer value, and resets the countdown. In other words, if you call llSetTimerEvent(n) every n-1 seconds, the timer() event will never fire.

To stop the timer, call llSetTimerEvent(0.0). It's good practise to do this in the state_exit() event of any state which uses a timer to avoid unintentionally having a timer running in the next state.


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

functions | events | timer
Comments [Hide comments/form]
So what's the maximum interval?
-- AjDasilva (2005-08-21 16:44:20)
Probably as big as the float type... good luck testing it :P
-- KeknehvPsaltery (2005-08-22 14:07:52)
probably 2 ^ 24 seconds as thats when the float would no longer be able to increment by 1.
Which is about 194 days.
-- BlindWanderer (2005-08-23 13:02:13)
What is the minimal interval, that does not shut it off?
-- ZenthereAridian (2006-03-21 09:30:31)
1.401298464E-45

That's as small as floats can get :D
-- KeknehvPsaltery (2006-03-21 14:24:58)
The tiny number that Keknehv posted may be the theoretical limit, but the practical limit is .022, or 1/45 second, which is the basic frame rate of SL and the interval at which scripts run.
-- ShirleyMarquez (2006-06-03 12:56:11)
There's a difference between the minimum "useful" value, and what Zenthere asked, which is the minimum positive number you can give it that llSetTimerEvent() will distinguish from 0.0 (which shuts it off). So Keknehv was right.
-- LexNevaForgotHerPassword (2006-06-04 15:50:35)
I think both are good to know ^_^
-- ChristopherOmega (2006-06-04 22:14:00)
BTW, the example should really use llOwnerSay("...") instead of llInstantMessage(llGetOwner(), ...). Sorry, just being a prude here — I know! :)
-- GwynethLlewelyn (2006-06-07 14:53:11)
Am I correct in assuming that only one llSetTimerEvent can be active in a state at one time? In other words, if I set the timer to 20 seconds in one part of my script, and later decide I want a timer event to be triggered in 1 second, does the second call to llSetTimerEvent replace the previous call, or does it add another one?
-- TexArmistice (2006-08-06 11:39:29)
It replaces the previous call.
-- KeknehvPsaltery (2006-08-07 07:13:03)
There seems to be a long standing issue where timers simply stop working for objects left out, usually after a sim restart or crash. Is there any work around for this? Using llSensorRepeat to restart the timer perhaps?
-- HeatherGoodliffe (2006-12-26 11:06:09)
probably not an easy solution for this, and definitely nothing you could program to work automaticaly.
-- BlindWanderer (2006-12-27 01:41:47)
This gets extremely inaccurate for short intervals (.1 sec or so) if there are more than about 4000 or so active scripts in a sim. It seems more of an issue with the number of scripts than how many instructions are being executed. If there are around 10000, it can be off by a factor of 4 or more for .1 second intervals. For intervals around 1 sec, it is much less sensitive, it seems to be an interrupt latency kind of issue.
-- RalphDoctorow (2007-01-06 11:49:25)
I am trying to scale an object at a rapid rate, using the timer event. Even though I set the timer to be 0.022 it still performs the scale every second instead. Is there a reason for this?
-- cpc1-hudd4-0-0-cust709.hudd.cable.ntl.com (2007-03-21 07:53:32)
can we have more than 1 timer in an object?
-- Bobbyb30 (2007-04-07 13:53:07)
If I call llSetTimerEvent(60) in my script, and then elsewhere (presumeably later) call llSetTimerEvent(60) again, does it reset the timer or continue with the original?

Meaning can I set a timer for certain events to occur and
A) they DO occur so I - 1-reset the timer, 2-{do other actions} 3-go back to waiting
B) they DO NOT occur so I - 1-do some actions

If I am using llSetTimerEvent(60) and the timer is reset at each call, I am fine, but if the timer does not actually reset there may (read WILL) be a problem. I am currently doing 2 call to reset the timer
{
llSetTimerEvent(0);
llSetTimerEvent(60);
}

but this is so wastefull, if not needed.
-- DavidSoon (2007-06-22 16:24:28)
Is there a function that can exit out of a script after x seconds of idleness and put it to it's default state?
-- c220-239-62-248.rivrw6.nsw.optusnet.com.au (2007-08-09 01:24:58)
Attach a comment to this page: