Originally Posted by Torhal
Not true.
Code:
do
local last_update = 0
local updater = CreateFrame("Frame", nil, UIParent)
updater:Hide()
updater:SetScript("OnUpdate",
function(self, elapsed)
last_update = last_update + elapsed
if last_update >= 0.25 then
RunSinFunction()
last_update = 0
end
end)
end
That executes the sin function every quarter of a second.
|
Code:
last_update = last_update -0.25
is more precise and does not skip seconds (even if this would just be some miliseconds) than reseting the whole value to 0 - (ie last_update could be 0.25182965 - so you would missing 0.00182965 - if you have this ~1000 times there's something missing