Stopwatch

Which is the best way to create a stopwatch  (mm:ss) ?

Take a look at the os.time and os.date (or system.getTimer if you need msec) … then when you touch a button, set some variable equal to the start-time; then have a timer.performWithDelay trigger updates every second (e.g. reading os.time and calculating the diff from start-time).

If you just use timer.performWithDelay, there is at least the potential for some skew in the times.  I.e. you may set it for 1 sec updates, but by the time the system actually executes your code, it might be 1.001 sec and eventually those 0.001 bits might accumulate and throw off your time.  By constantly diff’ing against a fixed time, you should avoid that accumulation.

Take a look at the os.time and os.date (or system.getTimer if you need msec) … then when you touch a button, set some variable equal to the start-time; then have a timer.performWithDelay trigger updates every second (e.g. reading os.time and calculating the diff from start-time).

If you just use timer.performWithDelay, there is at least the potential for some skew in the times.  I.e. you may set it for 1 sec updates, but by the time the system actually executes your code, it might be 1.001 sec and eventually those 0.001 bits might accumulate and throw off your time.  By constantly diff’ing against a fixed time, you should avoid that accumulation.