Jump to content
Sign in to follow this  
Calamari

llSensorRepeat as a timer ?

Recommended Posts

I thought I'd share this as I can see it could have some other uses, but I'm wondering if there's some reason this would be bad that I'm missing?

I coulden't use a timer event for this because the timer is all ready in use, and gets reset each time an avatar interacts with the object.  I'm using the no_sensor event as a 24 hour timer (it's ok if the times not exact) to reset the pos and rot to get rid of a small amount of drift from KFM.  I've tried this several other ways that work, but found the sensor to added the least amount of run time.

I thought this would be a really bad idea, but after trying it I'm surprised to see it's only adding about 0.00002 ms to the run time.  I see in the caveats there can be problems detecting near sim borders, but don't see that being a problem because it's set to never detect anything, an agent can't have a 1 letter name. 

 

default
{
    state_entry()
    {                      
        llSensorRepeat( "q", "", AGENT , 0.01, 0.01, 86400.0 );
    }
    no_sensor()
    {
        llOwnerSay("test");
    }
}

 

Share this post


Link to post
Share on other sites

That's one of many standard ways to run an extra timer in an LSL event.  It works well and with minimal effect on sim load, as you noted.  Especially when you are firing the sensor only once a day and looking 0.1m from your object, the load is really insignificant.

When I use this method, I have always looked for "Bill the Pirate", on the theory that pirates are very elusive and hardly likely to show up anywhere near anything I build.  :smileytongue:

Share this post


Link to post
Share on other sites


Rolig Loon wrote:

That's one of many standard ways to run an extra timer in an LSL event.  It works well and with minimal effect on sim load, as you noted.  Especially when you are firing the sensor only once a day and looking 0.1m from your object, the load is really insignificant.

When I use this method, I have always looked for "Bill the Pirate", on the theory that pirates are very elusive and hardly likely to show up anywhere near anything I build.  :smileytongue:

love your use of "Bill the Pirate"  I would have suggested using any linden name as completely safe, but glad to see the new CEO is ruining that option by letting Lindens back in world. :)

You got me curious about what the other standard methods to run extra timers are. I can think of several ways to count time but so far only the Sensor Repeat / no_sensor works exactly the same way as a timer that comes to mind.  I'll have to look in to that more.

Share this post


Link to post
Share on other sites

The other most common method is multiplexing. Start a heartbeat timer that triggers, say, once a second. Increment a counter each time it triggers. Then if you have events that you want to occur every 10 seconds, put a test in the timer event that says

if ( !gCount%10){    // Do my special thing}

 If you have some other event that should happen only once a minute, write

if ( !gCount%60){    // Do my other special thing}

 You can stack as many as you like.  You're just counting heartbeats.

Another method would be to run a timer in a second script in your object and then send a linked message to your main script when it triggers.

 

 

 

Share this post


Link to post
Share on other sites

Thanks Roling, My current project is using 3 times, 2 are multiplexing, one of those in a separate script that is turned off when not in use, plus a 3rd timer in the main script using sensor repeat.  I've been working a lot on reducing the number of timer used and thinking about when a time can or can't be combined.  I had learned the multiplexing from one of your other post it's been a big help thanks again :)  The term heartbeat timer got me thinking that here must all ready be terms for the ways I'm using timers or how they are set up, I think this will point me in the right direction of more things I need to look up.

Share this post


Link to post
Share on other sites

That's the price you pay for choosing a life on the bounding main, Bill.  If you had decided on a career as a CPA or an actuary, you could have been rolling in loot by now.  Chacun  a son goût.

Share this post


Link to post
Share on other sites


Rolig Loon wrote:

That's the price you pay for choosing a life on the bounding main, Bill.  If you had decided on a career as a CPA or an actuary, you could have been rolling in loot by now. 
Chacun  a son
goût.

How'd you know I've got gout?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...