Report post

Are you sure you want to report the post shown below? This will send an email to the ATVO administrators. Please include a short reason for reporting.

Users reporting for no reason may be locked out.


Post

Posted by Dwayne P
on
Kyle Heyer wrote:
Hi all,

Does anyone know how to properly format lap times in a script?

returning the FastestLapTime binding will give 71.xxx instead of 1:11.xxx - the only way I currently know how to format any sort of label binding like this is to do FastestLapTime.ToString("0.000").

What's the proper way to do this?

Thank you!

Kyle
If you click the link posted by Nick, you see a script of mine where I used a function to convert the exact same thing that you are looking for:
// If the car is in the same lap just return the time
// If the car is in same lap but over a minute behind, convert total seconds to proper format
var min = 0;
float sectime;
if (gap > 60)
{
    min = (int) (gap / 60);
            sectime = gap % 60;
            return "+" + min + ":" + sectime.ToString("00.000");
}
else
return "+" + gap.ToString("0.000");


Just make sure to add it on the proper spot in your script :)
Edit: you can swap out the "gap" variables for intervals too, just make sure the variable exists in your script.