Log In  

Cart #31219 | 2016-10-19 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Just a basic timer that I made to count seconds, minutes and hours. Plan on using it in a game to time special states.

P#31220 2016-10-19 08:21 ( Edited 2016-10-20 19:20)

I'm thinking this might not be very accurate when played Online as there is always some hiccup and stagger for some browsers.

Why not use TIME() instead ?

P#31237 2016-10-19 12:03 ( Edited 2016-10-19 16:03)

Because officially time() is "removed". Also because the number limit means you have to something along those lines anyway, so you might as well go all the way instead of relying on a function that may or may not return what you expect.

P#31245 2016-10-19 14:14 ( Edited 2016-10-19 18:14)

Tyroney, you know for a fact I had no way of knowing this useful function wasn't "available."


Searching the HELP, I do see it was "removed" back in v0.1.1.

Curiously though it still works fine here.

If ZEP planned to remove it as you say - well, as we are on version 0.1.9b - I think he may have missed. :)

P#31275 2016-10-19 23:08 ( Edited 2016-10-20 03:10)

This is useful, thanks. You may want to incorporate stat(1) to account for frame rate drops. Something like this:

local inc=flr(stat(1))+1
if timer1 < 30 then
    timer1 = timer1+inc

When the frame rate is the normal 30fps (stat(1) < 1), then inc is 1. At 15fps, it's 2, at 10fps it's 3, etc.

P#31276 2016-10-19 23:59 ( Edited 2016-10-20 06:02)

Thanks for the feedback and thanks for that tip musurca!

I did realize that if the FPS dropped, for whatever reason, then the timer would be effected. But I didn't know how to counter that. So I will incorporate that into the build.

P#31284 2016-10-20 03:09 ( Edited 2016-10-20 07:09)

To me the entire manual is kind of one big joke. Not that it's wrong or I don't respect it, but that its contents regularly make me laugh. (mostly at myself when I find/refind something that explains the hours of debugging I've been struggling with)

P#31317 2016-10-20 13:46 ( Edited 2016-10-20 17:46)

Tyroney, why is TIMER not supposed to work - when it does ?

Why was it to be removed ? I've already written a bit of code with it, and it seems to be a pretty darned accurate timer with no problems.

P#31321 2016-10-20 13:53 ( Edited 2016-10-20 17:53)

I was under the impression, looking at the wiki, that time() was initiated from cart boot?

Anyway the point of this system is that it is self contained. And cal be used in any situation.

P#31330 2016-10-20 15:20 ( Edited 2016-10-20 19:20)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 14:20:50 | 0.011s | Q:21