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 Kyle H
on
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.


Sorry to be such a nuisance - it must be irritating to have a double life as an "Intro to Programming" professor for people like us... One last question!

I am getting a compiler error

"LiveGap.cs (Line 20) 'ISessionResult' does not contain a definition for 'SessionFlags' and no extension method 'SessionFlags' accepting a first argument of type 'ISessionResult' could be found (are you missing a using directive or an assembly reference?)"


And since I have very little knowledge of C# (or any language for that matter) I've had trouble debugging. In the code I have what I want to do, hopefully I'm just missing something little. I promise. Last one.



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");


}


}
}