How to know if a timer is active

Hello, I am having trouble pausing/resuming some timers I have added to my program, the idea is to make a pause button , Here is a sample of the my code:

function pausaAc(e)  
 if pausaband then  
 if e.phase == "ended" then  
 pausaband = false  
 timer.pause(tmr)  
 for i=#topos,1,-1 do  
 if not (topos[i] == nil) then  
 topos[i]:pause()  
  
 timer.pause(topos[i].timer)  
  
 end  
 end  
 end  
 else   
 if e.phase == "ended" then  
 pausaband = true  
 timer.resume(tmr)  
 for i=#topos,1,-1 do  
 if not (topos[i] == nil) then  
 topos[i]:play()  
  
 timer.resume(topos[i].timer)  
  
 end  
 end  
 end  
 end  
 return true  
end  

Problem is some timers arent paused and I get errors saying
I cant stop/resume a timer that is already expired

It will really help me if there is a way to know if a timer is active or paused. [import]uid: 127101 topic_id: 30258 reply_id: 330258[/import]

I think the most reliable way is to just attach a status sub-variable to your timer.

tmr.status (it can be whatever you want to name it)

When you start the timer, set “tmr.status” to “running” or whatever you want to value it. When you pause it, just set “tmr.status” to “paused”. The value can be set or checked as needed, for example, if the timer status is “paused” the user can’t RE-pause it.

Do you think this will work for your needs?
Brent
[import]uid: 9747 topic_id: 30258 reply_id: 121212[/import]

You could provide some timer functions to do the work for you:

http://developer.coronalabs.com/code/timer-functions [import]uid: 8271 topic_id: 30258 reply_id: 121214[/import]

I think the most reliable way is to just attach a status sub-variable to your timer.

tmr.status (it can be whatever you want to name it)

When you start the timer, set “tmr.status” to “running” or whatever you want to value it. When you pause it, just set “tmr.status” to “paused”. The value can be set or checked as needed, for example, if the timer status is “paused” the user can’t RE-pause it.

Do you think this will work for your needs?
Brent
[import]uid: 9747 topic_id: 30258 reply_id: 121212[/import]

You could provide some timer functions to do the work for you:

http://developer.coronalabs.com/code/timer-functions [import]uid: 8271 topic_id: 30258 reply_id: 121214[/import]

For timers that run only once to launch a function, I use transitions simply to avoid the warning messages I get when I pause/resume all timers that have expired.   So instead of timer.performWithDelay(1000, myFunction), I do this.

transition.to(myFunction, { delay = 1000, time=0, transition=easing.linear, onComplete=function(target) target() end })

For timers that run only once to launch a function, I use transitions simply to avoid the warning messages I get when I pause/resume all timers that have expired.   So instead of timer.performWithDelay(1000, myFunction), I do this.

transition.to(myFunction, { delay = 1000, time=0, transition=easing.linear, onComplete=function(target) target() end })