Calculator Community > Lua |
Lua Q&A |
(1/42) > >> |
pianoman:
Hi everyone! I couldn't find a good place to post various questions, so I thought I'd start this. First of all, how do you use the timer and make it do something? All I can do is start it. :w00t: Thank you! |
Ashbad:
You can start the timer with Timer.start(period), which sets a period of time in seconds for the timer to start. You can then set up an on.timer() event that is activated every timer tick. You can stop it with timer.stop(). |
Jim Bauwens:
Here is a little example: --- Code: (Lua) --- number = 0 function on.paint(gc) --If number is still zero (we just started the application), start the timer (set to tick every 1 seconds) if number==0 then timer.start(1) end --Draw the number on the screen gc:drawString(tonumber(number),10, 10, "top") end --This get's now called every 1 seconds until you stop the timer function on.timer() --Add one to number number = number + 1 --Force the screen to be redrawn platform.window:invalidate() --If number is 10, stop the timer if number==10 then timer.stop() end end --- End code --- |
pianoman:
Oh, got it. Thanks! |
pianoman:
Another one: are you able to change values of an array in the program? Thanks! |
Navigation |
Message Index |
Next page |