Austin Darbyshire wrote:
right now the the first place car's live gap data on the ticker is blank. is there a way i can set it so it will just display "Leader" or "Live Gap" instead of a blank space?
Austin Darbyshire wrote:
i appreciate the help but my ticker is built a bit differently using the cloning and data offset so if put live gap on position 1 it would appear on all other positional cards
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Results;
namespace Scripts
{
public class test : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Bind to "entitysessionresult_object" value
// This puts the session result in the value as a type of IEntitySessionResult
// You must tell the compiler that this is the type you are expecting such
// that it knows what properties are available.
// Tell the compiler the value is of type IEntitySessionResult:
IEntitySessionResult result = (IEntitySessionResult) value;
// Check if driver is in first place
if (result.Position == 1)
{
// If so, return the text you want to display for P1
return "LIVE GAP";
}
else
{
// If not, return the live gap property
// The "ToString("0.0")" part controls how many decimals to display. Try "0.00" or "0.000" for example.
return result.LiveGap.ToString("0.0");
}
}
}
}
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Results;
namespace Scripts
{
public class test : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
IEntitySessionResult result = (IEntitySessionResult) value;
if (result.Position == 1)
{
return "LIVE GAP";
}
else
{
return result.LiveGap.ToString("0.0");
}
}
}
}
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Results;
namespace Scripts
{
public class LiveGap : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
IEntitySessionResult result = (IEntitySessionResult) value;
if (result.Out)
{
return "OFF";
}
else if (result.Position == 1)
{
return "LDR";
}
else if (result.LiveGap == 0.000)
{
return " ";
}
else
{
return result.LiveGap.ToString("-0.000");
}
}
}
}
using System;
using ATVO.ThemesSDK;
using ATVO.ThemesSDK.Data.Entity;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Controls;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Enums;
namespace Scripts
{
public class Script : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Bind to "entitysessionresult_obj" to get the IEntitySessionResult as the value
// Cast to IEntitySessionResult type
IEntitySessionResult result = (IEntitySessionResult) value;
// Check DNS, Out, Pits, etc
if (result == null)
return "";
if (result.DidNotStart)
return "DNS";
if (result.Out)
return "OUT";
if (result.Entity?.Car?.Movement?.IsInPits == true)
return "IN PITS";
if (result.Finished)
return "FIN";
// If none of these are true, then show the gap
// We need the following information to determine whether to show gap or laps
var pos = result.LivePosition;
var gap = result.LiveGap;
var laps = result.LiveGapLaps;
var type = result.Session.Type;
// Optional: there is no gap for P1 so show nothing
if (pos == 1)
return "";
// If car is lapped AND this is a race session,
// then show nr of gap laps instead of gap time
if (laps > 0 && type == SessionType.Race)
{
if (laps == 1)
return "1 Lap"; // to avoid incorrect "1 Laps"
else
return laps + " Laps";
}
// If the car is in the same lap just return the time
return gap.ToString("0.000");
}
}
}
Nick Thissen wrote:
Probably something like this:
var flags = result.Session.SessionFlags;
if (flags.HasFlag(SessionFlags.Caution) || flags.HasFlag(SessionFlags.CautionWaving))
{
return "Caution";
}
Nick Thissen wrote:
Just put it in the right order. Whatever check is true first will hit the "return" statement and end the script. So if you want DNS/PIT to show even when there is a yellow, you put them first so you don't end already on the yellow check.
using System;
using ATVO.ThemesSDK;
using ATVO.ThemesSDK.Data.Entity;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Controls;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Enums;
using ATVO.ThemesSDK.Data.Results;
namespace Scripts
{
public class Script : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Bind to "entitysessionresult_obj" to get the IEntitySessionResult as the value
// Cast to IEntitySessionResult type
IEntitySessionResult result = (IEntitySessionResult) value;
var flags = result.Session.SessionFlags;
// Check DNS, Out, Pits, etc
if (result == null)
return "";
if (result.DidNotStart)
return "DNS";
if (result.Out)
return "OUT";
if (result.Entity?.Car?.Movement?.IsInPits == true)
return "PIT";
if (result.Finished)
return "FIN";
if (flags.HasFlag(SessionFlags.Caution) || flags.HasFlag(SessionFlags.CautionWaving)){
return "";
}
// If none of these are true, then show the gap
// We need the following information to determine whether to show gap or laps
var pos = result.LivePosition;
var gap = result.LiveGap;
var laps = result.LiveGapLaps;
var type = result.Session.Type;
// Optional: there is no gap for P1 so show nothing
if (pos == 1)
return "LDR ";
// If car is lapped AND this is a race session,
// then show nr of gap laps instead of gap time
if (laps > 0 && type == SessionType.Race)
{
if (laps == 1)
return "-1 Lap"; // to avoid incorrect "1 Laps"
else
return -laps + " Laps";
}
// If the car is in the same lap just return the time
return gap.ToString("-0.000");
}
}
}
using System;
using ATVO.ThemesSDK;
using ATVO.ThemesSDK.Data.Entity;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Controls;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Enums;
using ATVO.ThemesSDK.Data.Results;
namespace Scripts
{
public class Script : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Bind to "entitysessionresult_obj" to get the IEntitySessionResult as the value
// Cast to IEntitySessionResult type
IEntitySessionResult result = (IEntitySessionResult) value;
var flags = result.Session.Flags;
// Check DNS, Out, Pits, etc
if (result == null)
return "";
if (result.DidNotStart)
return "DNS";
if (result.Out)
return "OUT";
if (result.Entity?.Car?.Movement?.IsInPits == true)
return "PIT";
if (result.Finished)
return "FIN";
if (flags.HasFlag(SessionFlags.Caution) || flags.HasFlag(SessionFlags.CautionWaving)){
return "";
}
// If none of these are true, then show the gap
// We need the following information to determine whether to show gap or laps
var pos = result.LivePosition;
var gap = result.LiveGap;
var laps = result.LiveGapLaps;
var type = result.Session.Type;
// Optional: there is no gap for P1 so show nothing
if (pos == 1)
return "LDR ";
// If car is lapped AND this is a race session,
// then show nr of gap laps instead of gap time
if (laps > 0 && type == SessionType.Race)
{
if (laps == 1)
return "-1 Lap"; // to avoid incorrect "1 Laps"
else
return -laps + " Laps";
}
// If the car is in the same lap just return the time
return gap.ToString("-0.000");
}
}
}
(line18) The type or namespace name 'IEntitySessionResult' could not be found (are you missing a using directive or eny assembly reference?)