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
Using Scripts for more advanced condition checks
Instead of checking a single Condition Flag, you can also use a Script to check a more complicated condition, such as a combination of multiple conditions or any other condition you can check in a script. The Script works the same as a regular converter script, with the only requirement that it should return a boolean value (true or false). If it does not return a boolean value the condition check will fail (and will pass by default).

To use a script, select the script in the dropdown under the Condition check for an action.


You can check the state of other condition flags with the Theme.ConditionalFlags.CheckState method. For example, the script below checks for several conditions to be met in a certain combination.

The action should only execute if:
  • C1 is set
  • AND (either C2 is set OR C3 is unset)
  • AND the current session state is Racing

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Enums;

namespace Scripts
{
    public class CheckCondition : IScript
    {
        public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
        {
            var c1 = item.Theme.ConditionFlags.CheckState("C1");
            var c2 = item.Theme.ConditionFlags.CheckState("C2");
            var c3 = item.Theme.ConditionFlags.CheckState("C3");

            return c1 && (c2 || !c3) && sim.Session.Current.State == SessionState.Racing;
        }
    }
}