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 Nick Thissen
on
Like I replied on the iRacing forums, the data we get from iRacing is that the length is 4.04 km, which is 2.51034 miles and not 2.5. We cannot fix that and I don't plan on overriding these kind of things just because they should be different. It's up to iRacing to fix this if it's a bug.

If you want to calculate an average speed with a different track length, you can very easily use a simple conversion script. Just bind to the fastest laptime (or previous laptime) binding instead of the "speed___" bindings, and then you can do the division yourself. For example:

using System;
using System.Linq;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;

namespace Scripts
{
public class conv : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var laptime = (float)value; // Laptime in seconds
var trackLength = 2.50f; // Hard-code 2.50 miles

var laptimeHours = laptime / 3600; // Laptime in hours
var speed = trackLength / laptimeHours; // Average speed in mph

return speed + " mph";
}
}
}


Perhaps the fastest laptime binding returns an already formatted laptime in which case the "value" you obtain is a string and not a floating point number. It is then maybe easier to bind to the "entitysessionresult_object" and obtain the FastestLapTime value from the result itself like so:

using System;
using System.Linq;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Results;

namespace Scripts
{
public class conv : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var result = (IEntitySessionResult)value;
var laptime = result.FastestLapTime;

var trackLength = 2.50f; // Hard-code 2.50 miles

var laptimeHours = laptime / 3600; // Laptime in hours
var speed = trackLength / laptimeHours; // Average speed in mph

return speed + " mph";
}
}
}