life regeneration by time like candy crush please help

Can someone help me build the function to count time before you get more lives… like in candy crush when your out of lives and it says to wait 10 minutes and you can be on the app or off how would I do this

Great question.  I’m trying to do something similar and I am having trouble figuring this out as well.

Call os.time() and store the result in a variable (say bonusStart) to get the time in seconds when you want to start the countdown. Use an enterFrame listener or a repeating timer to periodically check the current os.time() against the stored os.time(). When the difference reaches the required number of seconds, perform your action and store the os.time() again to begin a new countdown.

When the user closes the app, you’ll need to store the value of bonusStart on the device - I like the DMC Autostore or GGData libraries - and then retrieve this value when the user re-opens the app.

In order to avoid cheating you can instead retrieve the time from a server. I use http://timezonedb.com/ but you need to keep the calls to a minimum - only retrieve from the server when the app first runs, then use system.getTimer() to keep track of the current time from that point.

If you have say 5 game lives that will require a timer.  When one is used, what is the best way to select the table position (which of the 5 game life time slots) should be used? 

Thank you very much i was very lost… i forgot about ostime function… also i will post my code later if i have any more problems or a solution to this when im done… would you be kind enough to post your code on how to read that server from that site…

Also for more lives
I’m going to use it for 10 lives, so I would say if it’s 5 minutes for each level regeneration use what he said and use an if statement for when the difference is the first 5 add a live and the second 5 add another life but remember it’s in seconds

Great question.  I’m trying to do something similar and I am having trouble figuring this out as well.

Call os.time() and store the result in a variable (say bonusStart) to get the time in seconds when you want to start the countdown. Use an enterFrame listener or a repeating timer to periodically check the current os.time() against the stored os.time(). When the difference reaches the required number of seconds, perform your action and store the os.time() again to begin a new countdown.

When the user closes the app, you’ll need to store the value of bonusStart on the device - I like the DMC Autostore or GGData libraries - and then retrieve this value when the user re-opens the app.

In order to avoid cheating you can instead retrieve the time from a server. I use http://timezonedb.com/ but you need to keep the calls to a minimum - only retrieve from the server when the app first runs, then use system.getTimer() to keep track of the current time from that point.

If you have say 5 game lives that will require a timer.  When one is used, what is the best way to select the table position (which of the 5 game life time slots) should be used? 

Thank you very much i was very lost… i forgot about ostime function… also i will post my code later if i have any more problems or a solution to this when im done… would you be kind enough to post your code on how to read that server from that site…

Also for more lives
I’m going to use it for 10 lives, so I would say if it’s 5 minutes for each level regeneration use what he said and use an if statement for when the difference is the first 5 add a live and the second 5 add another life but remember it’s in seconds