Rich Price wrote:
Jean-Christophe, Could you share your settings and script for creating that popout for pit, dnf etc. It is the next thing I would like to add to my overlays. Thanks
Jean-Christophe Bouchat wrote:
Thanks Nick, it works well :)
I just needed to add the data.enums and also write correctly OffTrack (and not Offtrack... case sensitive).
'Offtrack' appears only when the car is out of the track and disappear immediately when the car come back to track. So the display could be very fast. Is there a way (script) to display 'offtrack' a little bit longer (a minimum time)? (with a fade out It will be the cherry on the cake ;) )
Quick question: Before I ask, I did a search on 'Offtrack' in data/object explorer... and I didn't find 'Offtrack'.
So, how can I suppose to find the solution by myself? :)
I'm glad that you provide me the solution... but I would like to know if it's possible to find the solution without you :)
EDIT: Unfortunately I have a (script) performance issue :(
Idk why but I have now this error:
Before that I had 30FPS and 8ms. Now my interface is really slow.
I'm using this script several times (Overall Top25, Class1 Top25, ... Class4 Top25) for Practice, Qualif and Race.
else
{
return "";
}
else
{
return null;
}
Console.WriteLine("Write this to the event log");
if (value == null)
{
// do something appropriate, in this case probably just return nothing
return null;
}
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Results;
using System.Collections.Generic;
using ATVO.ThemesSDK.Data.Enums;
namespace Scripts
{
public class Offtrack : IScript
{
// The time to display the text
private TimeSpan OfftrackShowTime = TimeSpan.FromSeconds(3);
// Store the time when the last offtrack was detected
// Store it separately for each car index
private Dictionary<int, DateTime> _offtrackStartTimes = new Dictionary<int, DateTime>();
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var result = (IEntitySessionResult)value;
var carIndex = result.Entity.CarIdx;
if (result.Entity.Car.Movement.TrackLocation == TrackLocation.OffTrack)
{
// Update the last detected offtrack time for this car index
_offtrackStartTimes[carIndex] = DateTime.Now;
}
// Check if there is a stored time
if (_offtrackStartTimes.ContainsKey(carIndex))
{
// If the stored time is shorter than the desired OfftrackShowTime, display offtrack
var elapsedTime = DateTime.Now - _offtrackStartTimes[carIndex];
if (elapsedTime < OfftrackShowTime)
{
return "OFFTRACK";
}
}
return "";
}
}
}