Conditional (If/Then/Else)
Conditional (If/Then/Else)¶
Evaluates a set of conditions and executes the "Then" commands if all conditions are met, or the "Else" commands if any condition fails.
Properties¶
System¶
| Name | Explanation | Type |
|---|---|---|
| Conditions | The conditions that must all be met for the "Then" commands to execute. If any condition fails, the "Else" commands are executed instead. | Condition |
| Else | The commands to execute when the conditions are not met. | Script |
| Then | The commands to execute when all conditions are met. | Script |
Examples¶
Execute Commands When Global Switch 0 is On¶
This checks if Global Switch 0 is on and executes the then-block commands if it is.
{"Data":{"Conditions":[{"$":"SwitchCondition","IsLocalSwitch":0,"SwitchComparison":0,"SwitchIndex":0,"Metadata":null}],"FailureCommands":[],"SuccessCommands":[{"$":"WaitCommand","Duration":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"1000","VariableIndex":0,"Metadata":null},"IsBlockingInput":false,"Metadata":null}],"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Flow.ConditionalCommand"}
Conditional with Both Then and Else Branches¶
This checks if Global Variable 0 is greater than 10. If true, it waits for 500 milliseconds. Otherwise, it waits for 2000 milliseconds.
{"Data":{"Conditions":[{"$":"VariableCondition","IsLocalVariable":0,"VariableIndex":0,"VariableComparison":4,"CompareToValue":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"10","VariableIndex":0,"Metadata":null},"Metadata":null}],"FailureCommands":[{"$":"WaitCommand","Duration":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"2000","VariableIndex":0,"Metadata":null},"IsBlockingInput":false,"Metadata":null}],"SuccessCommands":[{"$":"WaitCommand","Duration":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"500","VariableIndex":0,"Metadata":null},"IsBlockingInput":false,"Metadata":null}],"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Flow.ConditionalCommand"}