Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

os.time() changed event? [NOT SOLVED]

Asked by 9 years ago

I've been looking around for an event that fires every time os.time() changes. I'd prefer to not just have a 1 second loop that is off sync with the actual os.time(). Thanks in advance for any advice C:

1
Sadly, I do not think you can use something like the '.Changed' event to detect if the time has changed; You may have to use a Loop that loops every Millisecond. :( TheeDeathCaster 2368 — 9y

1 answer

Log in to vote
1
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

You can only find out by testing it out yourself. The only way I can think of executing code after os.time() increments is by checking the difference between the current time and the last. Test it out and compare it to waiting one second.

local tock = os.time()

spawn(function()
    while wait(1) do
        print(0/0)
    end;
end)

while true do
    if os.difftime(os.time(), tock) > 0 then
        warn(0/0);
        tock = os.time();
        wait"";
    end;
end;
Ad

Answer this question