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
You can achieve this with a similar script:

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

namespace Scripts
{
public class ChangeFocus : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
ControlInput input = null;

// Check if you want input 1 or 2
if (value?.ToString() == "1")
input = item.Theme.ControlInputs.Find("Input_CarNumber1");
else if (value?.ToString() == "2")
input = item.Theme.ControlInputs.Find("Input_CarNumber2");

if (input != null)
{
var carNumber = input.Text;
if (!string.IsNullOrWhiteSpace(carNumber))
{
// Find the corresponding entity (team entry)
var entity = sim.Session?.Entities?.SingleOrDefault(e => e.Car.Number == carNumber);
if (entity != null)
{
sim.CameraManager.Show(entity);
}
}
}
return null;
}
}
}


You can execute this script via the storyboard and also give it an input in the Value. This input is used in the script to check which input you want to use to get the carnumber. For example you can use "1" and "2" inputs, but you can easily extend this for more.

Once the input is found, you grab the Text to get the carnumber, and then find the corresponding entity. Then you can finally call the CameraManager again to show that entity.

The rest is a bunch of sanity checks to make sure the script does not throw errors (when you input an invalid carnumber or something or the carnumber is not in the session).