LSL Trick: Second Timer!
Let's say you're writing a script, and you need two timers. One might be a dialog timeout - if a dialog gets no response for 30 seconds, then stop listening (and allow another use to use the object). You might also need a second event to trigger periodically (every five minutes say) to do some maintenance.
Unfortunately, you can only have one timer event. Or can you?
There is a second repeating event: llSensorRepeat(). Now setting things up so this always triggers is pretty difficult. But llSensor and llSensorRepeat can trigger no_sensor events as well, if nothing is found.
So how do you set up a repeating sensor that has (a) minimal lag and (b) never triggers?
Lag is dependent on the specificity of your search, the range and angle searched, and how often the search is executed. Radars are notoriously laggy because they search for all avatars within a long range and a full sphere, usually at least once a second.
For minimal lag, we will search for a single person within a very small area, and only do so at longer intervals (over a minute between searches.)
And who is perhaps the least likely person to show up, that is still a valid key? (Because invalid keys are equivalent to searching for anybody). How about the Governor?
key GOVERNOR_LINDEN = "3d6181b0-6a4b-97ef-18d8-722652995cf1"; float TIMER = 300.0; // Five minutes default { state_entry() { // Governor only, within 1 centimeter *directly* ahead // Nearly impossible to trigger. llSensorRepeat("", GOVERNOR_LINDEN, AGENT, .01, .01, TIMER); } no_sensor() { // do your maintenance here! } }
And there you have it! (Of course, you could also allow sensor() to do the same maintenance if a miracle occurs and the Governor walks through your object. Or have it email you about the impossible happening!









