ID:1978866
 
(See the best response by Nadrew.)
Good morning everyone.

I'm trying to do something fairly simple, but I'm having a rough time.

This function is called regularly, but not always in the same interval (it's in a large list of other objects that get processed whenever we have the time).

/obj/item/device/process()
var/current = world.realtime // current tick
var/delta = (current - last_updated) / 10.0 // delta in seconds
last_updated = current
... scale various values using the delta ...


What I'd expect, would be that my delta value would represent the amount of time between process calls, but that only works if the value of 'world.realtime' is updated properly, which it isn't.

It appears to keep the same value for very long periods of time, up to 30 seconds at points during my tests.

Is there any way to get an accurate time delta or am I just going to have to re-code this with fuzzy 'sleep' statements?
Best response
You can use world.timeofday for a more accurate representation of time for the current day, however it resets daily. (it only includes time data, not date data, making it a smaller, more accurate value)
Ah... much better. Merci!