Animated 24 Hour Per Day Countdown Timer (day:hh:mm:ss)

  • #1, by afrlmeSaturday, 12. January 2013, 03:51 12 years ago
    script type: definition | syntax: n/a project file: here | pastebin: here

    Darkseed anyone? I have a migraine & it's only going to get worse in exactly 9 days & 24 hours from now!

    well quite frankly this was knackering! I kept tripping myself up & breaking the code as I wasn't used to using tables & the other methods divo implemented into the script ... but after a load of buggering around, I now have it working a-ok & relatively bug free! wink

    You can set up to 9 days & 24 hours on the clock; setting values higher or lower than the maximum/minimum values will result in them being automatically corrected ... due to various countermeasure if else statements I have included in the script!

    I have set all the values to 999 just to give you an example of what happens when you go over the default max value of each time value.

    replaced timer integer variables with actual values inside of the editor so that ... this script will auto resume from last saved time value when you load a save game or quicksave. the timer digits are split into single values located inside of the interfaces > timer_interface > values tab.

    I have also swapped everything over from the scene to an interface so that the timer can be displayed on any scene.

    if you don't want to display the timer permanently then you could create an action to fade in/out the interface every x amount of time or after a user completes x action etc!

    you can also speed up / slow down timer by changing the pause value via: characters > protagonist > called by other action "check_time" > pause ... pause value is set to 1 second by default which is real time ... set to 500ms for half time or 250ms for quarter time & so on etc.

    hopefully some of you ungrateful bugrits will appreciate this! AFRLme wink

    Imperator

    7278 Posts


  • #2, by BigStansSaturday, 12. January 2013, 12:23 12 years ago
    Cool, calling Jack Bauer grin

    Great Poster

    361 Posts

  • #3, by afrlmeSaturday, 12. January 2013, 12:27 12 years ago
    haha razz

    Imperator

    7278 Posts

  • #4, by afrlmeSaturday, 12. January 2013, 20:08 12 years ago
    ok dokie ...

    I'm a complete dimwit when it comes to maths ... I realized earlier the day that I didn't do the countermeasure part of the script correctly & have thus just spent a couple or so hours trying to figure out the exact code needed!

    the problem being is that because we are only allowing "x amount of days & 24 hours per day" to be displayed we needed to make sure that if a user enters a value greater than the max allowed values that they should be automatically corrected ...

    so far, so good ...

    the next problem was that we needed to check if the hour part was more than 19 hours & if so then max allowed value of single hour should be 4 (as in 24:00:00hrs) whereas if hours equals less than 20 hours then max allowed value should be 9 as in (19:00:00hrs)

    to get this to work correctly I had to split the countermeasure code into 4 parts ...

    part 1: check if total time is greater than 24 hours! if hour greater than or equal to 24 hours then time is automatically set to: 24:00:00hrs else ...

    part 2: check if each individual value is greater than max value! if x value is greater than max value then do ... end

    part 3: check if each individual value is less than min value! if x value is less than min value then do ... end

    part 4: double check the values & set any that have not already been set! if x is greater than or equal to min value and x is less than or equal to max value then x = x + 1 end

    quick note you may notice in the script I have added +1 or -1 to certain things in the script ... this is because table values do not start at 0, they start at 1!

    so to display animation frame 0 we need to set value to 1 ... or to display animation frame 9 we need to set value to 10 etc!

    P.S: I have now have a worse headache than yesterday!

    I have updated the pastebin, project file folder & wiki with the new changes. I added the old script into the revisions folder found inside of project root folder > scripts > revisions ...

    I have also added some annotated screenshots to the first post to explain some of the stuff inside of the editor!

    Imperator

    7278 Posts

  • #5, by andy-rinaldiFriday, 18. July 2014, 18:51 10 years ago
    Hi,
    I have a counter in my option menu which appears and disappears changing the cursor focus out or in the option menu. Now when the option menu appears again, the timer resets and starts from 0. My counter is a images timer. How can I save the timer when my option menu disappears?

    thanks.

    Forum Fan

    160 Posts

  • #6, by afrlmeTuesday, 22. July 2014, 12:56 10 years ago
    By using values inside of the editor. I wrote this ages ago, so I don't exactly remember the ins & outs of how it functioned, off the top of my head.

    Ideally what we would do is set the intial time into values & have it check the values & update the timer images each time the counter is shown, or something. Technically I believe it would actually be even possible to do this with a single value & use lua script & a bit of math to split the value into hours, minutes & seconds.

    Imperator

    7278 Posts

  • #7, by andy-rinaldiTuesday, 22. July 2014, 20:37 10 years ago
    Your script works fine but I use it in my option menu that I created as interface and when going to the game, and then back to the option menu, the timer restarts from 0. How can I fix it?

    Forum Fan

    160 Posts

  • #8, by afrlmeTuesday, 22. July 2014, 20:50 10 years ago
    can you tell me what the timer is for please?

    Imperator

    7278 Posts

  • #9, by andy-rinaldiWednesday, 23. July 2014, 11:43 10 years ago
    I sent you a PM.

    Forum Fan

    160 Posts