From Inspired-Lua Wiki
Revision as of 19:39, 7 January 2012 by Adriweb (talk | contribs) (→‎Example)
Jump to navigation Jump to search

timer.start is a function that is part of the timer functions.

Starts the timer with the given period in seconds.
If the timer is already running when this routine is called, the timer is reset to the new period.

This function fires the on.timer() event.

This has been introduced in TI-Nspire OS 3.0 (Changes).



Parameter Type Description
number the time period in seconds for the timer to start. Must be > 0.01


This example will display on the top-left corner of the screen a number going from 0 to infinity (it never stops), by adding 1 to variable every 0.5 seconds.

variable = 0

function on.timer()
   timer.stop()  -- stops the current timer. Not necessary.
   variable = variable + 1
   platform.window:invalidate()  -- screen refresh (on.paint is called)

function on.paint(gc)
   timer.start(0.5)  -- will fire the on.timer event every half second.
   gc:drawString(variable,0,0,"top")  -- display the number

See also