Countdown time from a set variable

Hey, me again! I am working on pulling apart some code from Peach Pellen at Techority, to do with Countdown. She has a script there that counts down to christmas.

Here is the script
http://techority.com/2011/12/07/making-a-countdown-app-with-corona-sdk/

So far i have set three global variables as follows

[lua]globalDays = 0
globalHours = 0
globalMinutes = 0[/lua]

A user enters their values via some input boxes on a screen, and i have them working fine.

What i can’t get my head around is modifying the script properly. At the moment, it takes the CURRENT hour, minute,second and counts down from that. However i need it to start counting down from the hour, minute,second that the user specified.

I can’t get my head around it. Here is a sample of the code that is working the hour out.

[lua]local hoursLeft = 23 - time.hour
if (hoursLeft < 10) then
hoursLeft = “0” … hoursLeft
end
hourText.text = hoursLeft -1[/lua]

Now i know it is time.hour that is pulling in the current hour in the day, and i know how to replace it to show the hour the user chose, but then it stops counting/ticking over.

Any help or a friendly nudge in the right direction would be great :slight_smile: Then i think i am nearly finished in my app :slight_smile: [import]uid: 120612 topic_id: 26677 reply_id: 326677[/import]

A nudge:

  1. Let user pick the time/date
  2. Once they have finished, cancel the current countdown
  3. re-assign the variables you are using to use the ones inputted by the user
  4. Start your timer going again [import]uid: 84637 topic_id: 26677 reply_id: 108637[/import]