Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How Reliable IS the llGetTime function?

Edison Swain
Registered User
Join date: 7 Dec 2006
Posts: 51
01-13-2007 22:42
Hi all,

I know that the wiki contains some warning information about using llGetTime. Basically, it seems that the Time can get reset on a whim.

But honestly, how often do people see this happening? I have an state that needs to use llSensor to check for the presence of another object. I use llSetTimerEvent to run the sensor every 1 second. If it doesn't find it in 30 seconds, well, it's time to move on. llResetTime and llGetTime would make this very simple (call llResetTime in my state_entry, and then check llGetTime < 30 in my timer event)

It's not crucial that the script cuts out at 30 seconds. For example, if it got up to 20 seconds, and then reset the time through some weird unreliable glitch, I simply end up scanning for 50 seconds. If this happens once every thousand times - no big deal. If it happens once every hundred times, I can probably still live with it. But if it happens once every ten times, then it's probably too much of an annoyance and I'll have to do it another way. (But I HATE throwing in unnecessary variables when I don't have to! :) )

So any one have any reliable data on just how unreliable llGetTime can be?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-13-2007 23:57
Any reason you are using llSensor instead of llSensorRepeat?

If your worried about using llGetTime why not just use a simple counter inside the sensor and no_sensor events?
Edison Swain
Registered User
Join date: 7 Dec 2006
Posts: 51
01-14-2007 00:39
From: Newgate Ludd
Any reason you are using llSensor instead of llSensorRepeat?


Mainly because I'm an idiot! :) When I read the wiki, I misunderstood the reasons for when and why you should use llSensor instead of llSensorRepeat! Once you mentioned this, I went back and read it again - and realized I was understanding it wrong!

Thanks Newgate!

From: Newgate Ludd
If your worried about using llGetTime why not just use a simple counter inside the sensor and no_sensor events?


That was my backup plan - but it felt like a work around. And when programming, I hate using a work around if the thing I'm trying to work around actually does work! :)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-14-2007 02:30
From: Edison Swain
Mainly because I'm an idiot! :) When I read the wiki, I misunderstood the reasons for when and why you should use llSensor instead of llSensorRepeat! Once you mentioned this, I went back and read it again - and realized I was understanding it wrong!

Thanks Newgate!



That was my backup plan - but it felt like a work around. And when programming, I hate using a work around if the thing I'm trying to work around actually does work! :)



Sometimes it is the simpler idea that works better.
You have no need to use a timer, Your sensor repeat is giving you the timer functionality, all you need to do is keep track of how many have occurred.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
01-14-2007 11:46
sensor repete is the way to go but back to your original question ive never seen get time just up and reset under normal operating conditions

now just about any server burp and (altho i cant test it right now) crossing sim boundrys will goof it up ... so if you do choose to use it make shure it is nothing mission critical

ie in my rss<-> llDialog script i have a llGet time setup where if noone has used the object within 5min it refreshes the data on next use ... thats fine becuase headlines on the linden blogs never change that quickly and if someone gets some old data its no big deal

but later on i still define a timer to shut off the listener becuase IMO that is mission critical (to save some cpu cycles) and i dont want it to be on a timing system that could be goofed up verry ezly


ive stated before that i think the wiki text on the subject is abit harsh, there are some limited uses for the functions ... altho 99% of the time it is unwise to use
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
01-14-2007 11:56
I agree, I think the wiki is definitely too harsh on this subject. In fact, I think it's just plain wrong and needs to be rewritten.

I use llGetTime() all the time, for things similar to what you're describing and for other purposes. For the former, while someone has shown you that you can use llSensorRepeat(), sometimes there's not a built-in solution like that. Using a simple counter in a timer() event is definitely not very accurate, because you have no guarantee that timer() events happen exactly on time (and, in fact, they often fire late). Use a counter, and you could end up with your secondary event happening much later than you intended. Use llGetTime(), and you're likely to be accurate even if the sim hits 0.01 time dilation for a little while.

There llGetTime() really shines is physical interactions. Often, I want to be controlling a physical object as closely as I can, or at least reasonably closely, and more importantly, precisely. I'll set a timer of 0.2 or so, but I know that the timer won't happen exactly ever 0.2 seconds... each interval will probalby vary a fair bit. So if, say, I'm intending to accelerate an object at 5m/s, rather than applying an impulse of exactly 1m/s * llGetMass() every timer() event and hoping that there are exactly five timer() events fired per second, I apply an impulse like this: llGetAndResetTime() * 5 * llGetMass().

This means that the impulse I'm applying scales, and should be relatively accurate for a wide range of sim behavior. My script does "the right thing" no matter the timeslice it's been given, within reason.

I don't think I've ever seen llGetTime() reset on me randomly, especially if the script running it never goes over any sim boundaries or anything like that. I don't think it resets randomly, and I think it was built to be used in real-time applications like what I've described above. That said, even if the time DID reset on a whim, it's likely that I wouldn't get more than a hiccup that corrected itself shortly after.

Maybe we should rewrite the wiki entry.
Edison Swain
Registered User
Join date: 7 Dec 2006
Posts: 51
01-14-2007 14:28
Thanks for the feedback, everyone. It's good to know the experience of others with this.