displaying time with hrs:mins:secs and decimal points
RossmanBrothersGames
Member Posts: 659
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
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().
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
That makes sense. Not at my computer right now but will give that a try later. Thanks @tatiang
www.rossmanbrosgames.com
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)
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@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.
www.rossmanbrosgames.com
You're welcome!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User