WARNING: timer.pause()

I get a 

WARNING: timer.pause() cannot pause a timerId that is already expired.

Does that really matter? Do warnings matter? It seems rather harmless.

I am running everything on to pause, stop then cancel them when I switch scenes so I don’t have any lingering events or anything. But I guess I try to pause something that has already been run that way?

easily overcome by testing if it is true first

once the timer has run the variable will go false

EDIT works the same for timer.pause  :smiley:

local myTimer if myTimer then timer.cancel(myTimer) end

oh. ok. I’ve been using timer2 so I just set my timers like:

timer.performWithDelay( 600, PanCamera,1, “timer” ) timer.performWithDelay( 2000,showButton,1, “timer” )

but that makes sense. I can get a nil on timer.show to check that way I guess.

you need to assign the variable to the timer for this to work, otherwise you have no way to reference it.

i have no idea what the last parameter (“timer”) in your timer call is supposed to do, and it’s not mention in the documentation.

local myTimer -- create timer myTimer=timer.performWithDelay(600,PanCamera,1) -- cancel timer if myTimer then timer.cancel(myTimer) end

dont forget about lua scope when coding this.

i have no idea what the last parameter (“timer”) in your timer call is supposed to do, but checking documentation I see no reference to it.

EDIT - There is no need to set the repeat parameter if your timer is a one-shot

Corona is well documented. Always check with it first  :smiley:

That’s was my timer tag so I could target cancel on various objects…

I am using timer2.lua. But I guess maybe I should think about pulling all that out.

What is timer2.lua?

Rob

Yah what is timer2.lua

well, Mr Lava Level seems to have disappeared. But I’m fairly sure he’s referring to Jason Schroeder’s timer library:

http://www.jasonschroeder.com/2015/02/25/timer-2-0-library-for-corona-sdk/

Well, the warning is harmless. Timers, can’t be paused after they expire. But they are expired so trying to pause it causes no harm.

Rob

Hey, thanks to all on this thread for reminding me of my old timer2 module, which I hadn’t revisited in quite some time. I was inspired to make some tweaks that both simplified the overhead for timer.pause() timer.resume() and timer.cancel() calls, and also eliminated the needless warnings for expired timers when calling timer.pause() and/or timer.resume().

@LavaLevel, assuming you were using my timer2 module (it has been forked, so it’s possible you were using somebody else’s fork), you can grab the new version from GitHub and that should get you squared away.

Heres the GH repo for the module: https://github.com/schroederapps/corona-timer2

easily overcome by testing if it is true first

once the timer has run the variable will go false

EDIT works the same for timer.pause  :smiley:

local myTimer if myTimer then timer.cancel(myTimer) end

oh. ok. I’ve been using timer2 so I just set my timers like:

timer.performWithDelay( 600, PanCamera,1, “timer” ) timer.performWithDelay( 2000,showButton,1, “timer” )

but that makes sense. I can get a nil on timer.show to check that way I guess.

you need to assign the variable to the timer for this to work, otherwise you have no way to reference it.

i have no idea what the last parameter (“timer”) in your timer call is supposed to do, and it’s not mention in the documentation.

local myTimer -- create timer myTimer=timer.performWithDelay(600,PanCamera,1) -- cancel timer if myTimer then timer.cancel(myTimer) end

dont forget about lua scope when coding this.

i have no idea what the last parameter (“timer”) in your timer call is supposed to do, but checking documentation I see no reference to it.

EDIT - There is no need to set the repeat parameter if your timer is a one-shot

Corona is well documented. Always check with it first  :smiley:

That’s was my timer tag so I could target cancel on various objects…

I am using timer2.lua. But I guess maybe I should think about pulling all that out.

What is timer2.lua?

Rob

Yah what is timer2.lua

well, Mr Lava Level seems to have disappeared. But I’m fairly sure he’s referring to Jason Schroeder’s timer library:

http://www.jasonschroeder.com/2015/02/25/timer-2-0-library-for-corona-sdk/

Well, the warning is harmless. Timers, can’t be paused after they expire. But they are expired so trying to pause it causes no harm.

Rob

Hey, thanks to all on this thread for reminding me of my old timer2 module, which I hadn’t revisited in quite some time. I was inspired to make some tweaks that both simplified the overhead for timer.pause() timer.resume() and timer.cancel() calls, and also eliminated the needless warnings for expired timers when calling timer.pause() and/or timer.resume().

@LavaLevel, assuming you were using my timer2 module (it has been forked, so it’s possible you were using somebody else’s fork), you can grab the new version from GitHub and that should get you squared away.

Heres the GH repo for the module: https://github.com/schroederapps/corona-timer2