Is there an simple way to format a timer value to minutes / seconds / 100ths

Hi there,

I have a timer counting up in my game but it’s pretty simple and a time of say 1 minute 10 seconds and 65 hundredths of a second will show as 70.65.

I was just wondering if there was a simple way to format that to 1:10:30 ?

Thanks
Pete

Not sure if there’s a built-in way, but modulus and integer division will do it pretty easy for you:

function Format( time : float ) : String {
 var seconds : int = time;
 // minutes = 1 per sixty seconds, no more than 59 minutes displayed
 var minutes : int = seconds / 60 % 60;

 // hours = 1 per 3600 seconds
 var hours : int = seconds / 3600; // add % 24 if you want it in a 24-hour scale only


 // hundredths = decimal part of time * 100, rounded down
 var hundredths : int = (time-seconds) * 100;

 // now make seconds no more than 59
 seconds %= 60;

 return hours + ":" + minutes + ":" + seconds + "." + hundredths;
}

Hey Vicenti!
I thought I must have been missing something really simple, but your script works great!
Thanks for the help!