displaying time with hrs:mins:secs and decimal points

Hey everyone thanks to an old thread by @gyroscope I was able to get my game time displayed in hrs:mins:secs, however I need it to display with two decimal points also showing tenths and hundredths of a second: "0:00:00.00"
Any math geniuses able to help? I've been trying to figure it out.

Here is what I have for hrs:min:secs:

floor( self.time /3600)..":"..floor(floor(( self.time %3600)/60)/10)..floor((floor( self.time %3600)/60)%10)..":"..floor(( self.time %60)/10)..floor( self.time %10)

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    Not positive about this but I think you could get hundredths of a second with roundTo(self.Time,2)-floor(self.Time).

    Edit: I would use prec(self.Time,2) instead. It looks much smoother than roundTo().

  • That makes sense. Not at my computer right now but will give that a try later. Thanks @tatiang

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    Here's the best expression I came up with:

    prec(self.Time-floor(self.Time),2)

    However, every second, it displays 1.00. I'm not sure why...

    And a bandaid solution for that problem is:

    textSubStr(prec(self.Time-floor(self.Time),2),3,4)

  • @tatiang thanks a lot for taking the time. I had to change it a little bit but your logic got it for me!
    I was able to use your first equation since I didn't need this for an active time but rather for a high score display. And lastly I had to multiply it by 100 to make it 00 rather than 0.00 to place at the end of what I already had. Appreciate it, my brain wasn't working.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You're welcome! :)

Sign In or Register to comment.