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

Hi, i have timers in my game stored in a table called lvlTimers.

lvlTimers={}

Some are never-ending and some only fire once called at different times.

when i pause the game i pause all timers using:

local i = 0

for i = #lvlTimers, 1, -1 do

     timer.pause (lvlTimers[i])

end

Then the same for resume game. My problem is i keep getting the terminal warning:

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

I know it’s because the timers that fire once are expiring and shifting the table values. but i cant seem to remove them with table remove because their place gets shifted with various timers expiring etc.

and if i use:

  if lvlTimers[i] ~= nil then

     timer.pause (lvlTimers[i])

   end

instead of just: timer.pause (lvlTimers[i]) then some timers don’t get paused (even if i nil them out in their function!)

Will my game get rejected from apple or google for having these warnings??

I’ve read no they’re just warnings but surely if someone plays the game for an extended period of time the expired timers will build up and up and there would be hundreds of terminal warnings?

Please someone help me out it’s driving me crazy!

Thanks!!

Finn

solved for timers that fire once using this in the end of the timers function:

 

for k,v in pairs ( timers ) do
    if ( v == e.source ) then
    table.remove ( timers, k )
    print ( "Complete: "…k, e.source, #timers )
    end
    end

 

or if fires more than once but not never-ending then check how many counts it’s done then call that for loop.

 

What i cannot figure out is how to do this when cancelling timers, so if i cancel a timer that’s somewhere in the table i want to remove it from that table but can’t because the order’s been all jumbled up. please someone help!!!

solved for timers that fire once using this in the end of the timers function:

 

for k,v in pairs ( timers ) do
    if ( v == e.source ) then
    table.remove ( timers, k )
    print ( "Complete: "…k, e.source, #timers )
    end
    end

 

or if fires more than once but not never-ending then check how many counts it’s done then call that for loop.

 

What i cannot figure out is how to do this when cancelling timers, so if i cancel a timer that’s somewhere in the table i want to remove it from that table but can’t because the order’s been all jumbled up. please someone help!!!