timer()
The
timer event is raised at regular
time intervals set by the
llSetTimerEvent function (you only need to
call this function once).
Note: an event will never run while another event is still executing. The
timer event will get
queued and be executed after the previous events are dequeued. In other words,
llSetTimerEvent only specifies the amount of time that must pass before a
timer event is put into the event
queue, which is not necessarily the same as the amount of time before the next
timer event actually runs.
The
timer event interval can be changed randomly each time it's called by putting:
in the
timer event itself, where "
#" is the upper
value.
llFrand will
return a random result between 0 and
#.
Specifics:
When a
timer event is specified, it does not immediately fire; rather, it waits the allotted amount of time before triggering the first
timer event. So, if
llSetTimerEvent(3600); it must wait one hour (60 minutes = 60 seconds x 60 = 3600 seconds) for it to trigger the first event.
To trigger the event once before waiting the time set, create a function with what it is to do, call it, call
llSetTimerEvent, and then call the function in the
timer event:
The way the
timer event works is: wait, do event, wait, do event, wait, ...
The way the above script works is: do event, wait, do event, wait, do event, ...
For the timer to do something different depending on some condition, use an
if statement that checks a global
variable. The following example uses a
touch event to set the global variable that the
timer event checks:
Note: the second
if statement is only necessary in a
touch event if there is also an
if-else in the
timer event; it won't work as
else otherwise, oddly. However, simply remove the
timer's
if-else and code as above and this won't be a problem.
Events |
Time