Fastest Lap of the Race

Posts: 53
Hello,

I'm looking for advice. We're using spreadsheets to show driver's name, car and team on the screen, and I want to create a widget to show the fastest lap of the race. That leads me to a question. I can't use 'sessionstate' data set because the editor doesn't allow me to do Data Binding with spreadsheet data. If I use Standings, it's going to give me only the FL of the P1 driver, which isn't correct for the race. Is it safe to use 'selected' data set which is going to select 'current session'? Or do you have any other tips?

Thanks!
Posts: 785
I'm not sure if I understand your problem. In the "sessionstate" data set there are a number of bindings related to the fastest lap; they all start with "fl_...". For example "fl_time", "fl_fullname", "fl_teamname", etc. Does that not work for you? It should be the fastest lap of the current session, not just P1.

You may have to be present in the sesssion to observe the fastest lap happening otherwise some details could be missing (not entirely sure).

The "selected" dataset is the same type of dataset as "standings", "warmup", "qualification", etc, except you can choose at any point to switch sessions by using the Timing screen. In the "Sessions" tab you can select a session, and that will switch the "selected" dataset to use data from that session.
Edited (1 time)
Posts: 53
Nick Thissen wrote:
I'm not sure if I understand your problem. In the "sessionstate" data set there are a number of bindings related to the fastest lap; they all start with "fl_...". For example "fl_time", "fl_fullname", "fl_teamname", etc. Does that not work for you? It should be the fastest lap of the current session, not just P1.

Of course, that works, but unfortunately, I can't use "sessionstate" because in Data Binding I cannot find/select data from the spreadsheet, unlike in Standings or Followed etc.

We load the driver's name and their team from our internal spreadsheet, not from the game.
Posts: 785
I see. The only way to do that is with scripting. You could use an Event Trigger to trigger on FastestLap and run a script. In the script you can find out the id of the driver that set the lap, and the laptime. Then you can look up the driver details in the spreadsheet. I don't have time to write up an example right now, but there's a couple examples of looking up data from a spreadsheet if you search on this forum.
Posts: 53
Nick Thissen wrote:
I see. The only way to do that is with scripting. You could use an Event Trigger to trigger on FastestLap and run a script. In the script you can find out the id of the driver that set the lap, and the laptime. Then you can look up the driver details in the spreadsheet. I don't have time to write up an example right now, but there's a couple examples of looking up data from a spreadsheet if you search on this forum.

Ah, ok, so a script. I'm not very good at scripting (without a comprehensive manual), but I'll try to look at some examples.
Posts: 40
hi . I build a anmiation of my Fastest lap of race Witget, the anmiation is 12 sek Long , fade in and fade out ;)
Posts: 28
Are you able to provide advice on how you achieved that please?
Posts: 287
Use Event trigger with Event type: Fast Lap
Create your animation
And add Control/action in Even trigger --> Animation Start (your animation with your widget)
Edited (2 times)
Posts: 287
for more action, use StoryBaord ;)
Posts: 53
So, I finally had some time to look at it. However, I think I've found small complication, but maybe I've missed something. I was purely checking the SDK for this and my goal is to get a Customer ID of a driver who sets the fastest lap of the race, so I can load his name from a custom spreadsheet.

The FastestLap Driver data is saved in ISessionResult, which points to IDriver. However, that doesn't hold any Customer ID information. That is only in IEntity, so I need to use IEntitySessionResult.

So the only idea I have, is to use the overall Fastest Lap time from ISessionResult, compare it to every driver's fastest lap in IEntitySessionResult and once there is a match, then to proceed to load Customer ID through IEntity?
Posts: 785
IDriver inherits IEntity, so IDriver has the customer ID as well under the Id property.

I do think the SDK does not give us the customer ID that set the fastest lap, but only the car index. So in a team race, where multiple people can drive the same car, we do not always know which of those drivers set the fastest lap, we only know which car was used to set it. I think we do link the information of the fastest customer ID when you are in the session (so you see it happening live), but if you were not in the session at the time that the lap was set, there is no way to retrieve the info anymore.
Posts: 53
Nick Thissen wrote:
IDriver inherits IEntity, so IDriver has the customer ID as well under the Id property.

Oops, completely missed that! Now that made things much easier and I've got it working. Thank you!

Here I'm posting the code, in case anybody would need it.

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


namespace Scripts
{
public class fastlap : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
ISessionResult fl = (ISessionResult) value;

int id = fl.FastestLapDriver.Id;
string name = "";
string team = "";

if (id != 0)
{
var sheet = item.Theme.Spreadsheets.Find("Drivers.csv");

foreach (var row in sheet.Table.Data.Rows.OfType<DataRow>())
{
int idcheck = Convert.ToInt32(row[0]);

if (idcheck == id)
{
name = row[2].ToString();
team = row[3].ToString();
}
}
}

string result = name + " - " + team;
return result;
}
}
}