Displaying game time in (hrs:min:sec)

j75j75 Member, PRO Posts: 235
I have an attribute that increases by one every second.

I found a tutorial which explains how to take this attribute and change it to a time format showing minutes and seconds in the display text expression editor e.g. 00:00

What I need to know is how to add hours as well e.g. 00:00:00

----------------------------------------
What I have working for min and sec is below:

floor(floor(( game.TotalTimeSpinning %3600)/60)/10)
..floor((floor( game.TotalTimeSpinning %3600)/60)%10)
..":"..
floor(( game.TotalTimeSpinning %60)/10)
..floor( game.TotalTimeSpinning %10)
-----------------------------------------

I know it's easy math but my brain is fried right now and I can't figure the equation to show the hours.
Any help would be appreciated.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi,@jesse75, yup, I get fried brains too, especially at 1 in the morning... :-)

    Here is the hrs:mins:secs as you want:


    floor(( game.TotalTimeSpinning )/3600)..":"..floor(floor((( game.TotalTimeSpinning )%3600)/60)/10)..floor((floor(( game.TotalTimeSpinning )%3600)/60)%10)..":"..floor((( game.TotalTimeSpinning )%60)/10)..floor(( game.TotalTimeSpinning )%10)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • j75j75 Member, PRO Posts: 235
    ahhh. Thank you!
  • BagzliBagzli Member, PRO Posts: 48
    edited May 2015

    I know this is few months old but for anyone who wanted to have 00.00.00 format as oppose to 0.00.00 that is shown up there you can use the following:

    for clarification, game.TotalTimeSpinning is the variable that keeps track of your time in seconds.

    floor(floor((game.TotalTimeSpinning)/3600)/10)..floor((( game.TotalTimeSpinning )/3600)%10)..":"..floor(floor((( game.TotalTimeSpinning )%3600)/60)/10)..floor((floor(( game.TotalTimeSpinning )%3600)/60)%10)..":"..floor((( game.TotalTimeSpinning )%60)/10)..floor(( game.TotalTimeSpinning )%10)

    I'm posting this as I wanted this myself and I figured some others might too.

    Thanks for your answer gyroscope, it helped me a lot!

  • cao cao xgsxcao cao xgsx Member, PRO Posts: 10

    thanks all this just saved me hours :)

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2016

    @cao cao xgsx said:
    thanks all this just saved me hours :)

    You could also use the more simple:

    padInt( game.Clock.Hour ,2)..":".. padInt( game.Clock.Minute ,2)..":"..padInt( game.Clock.Second ,2)

Sign In or Register to comment.