Switch Conditional
Switch Conditional¶
Evaluates multiple cases in order and executes the commands for the first case whose conditions are met.
Properties¶
System¶
| Name | Explanation | Type |
|---|---|---|
| Default Commands | The commands to execute when none of the switch cases match. Acts as the fallback or "else" branch. | Script |
| Switch Items | The list of cases in the switch conditional. Each case has its own conditions and commands to execute when matched. | Array |
Examples¶
Switch with Two Cases and a Default¶
This evaluates multiple cases in order. If Global Variable 0 equals 1, the first case executes. If it equals 2, the second case executes. Otherwise, the default block runs.
{"Data":{"DefaultCommands":[{"$":"WaitCommand","Duration":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"500","VariableIndex":0,"Metadata":null},"IsBlockingInput":0,"Metadata":null}],"IsTimeConstrained":1,"SwitchItems":[{"Commands":[{"$":"WaitCommand","Duration":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"100","VariableIndex":0,"Metadata":null},"IsBlockingInput":0,"Metadata":null}],"Conditions":[{"$":"GlobalVariableCondition","ComparisonGlobalVariableIndex":null,"ComparisonLocalVariableIndex":null,"Index":0,"Operand":0,"Value":"1","Metadata":null}],"IsDefaultSet":0,"Name":"","Metadata":null},{"Commands":[{"$":"WaitCommand","Duration":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"200","VariableIndex":0,"Metadata":null},"IsBlockingInput":0,"Metadata":null}],"Conditions":[{"$":"GlobalVariableCondition","ComparisonGlobalVariableIndex":null,"ComparisonLocalVariableIndex":null,"Index":0,"Operand":0,"Value":"2","Metadata":null}],"IsDefaultSet":0,"Name":"","Metadata":null}],"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Flow.SwitchConditionalCommand"}
Switch with Named Cases¶
This uses named cases for editor readability. The name is a label that appears in the editor for organizational purposes.
{"Data":{"DefaultCommands":[{"$":"WaitCommand","Duration":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"500","VariableIndex":0,"Metadata":null},"IsBlockingInput":0,"Metadata":null}],"IsTimeConstrained":1,"SwitchItems":[{"Commands":[{"$":"WaitCommand","Duration":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"100","VariableIndex":0,"Metadata":null},"IsBlockingInput":0,"Metadata":null}],"Conditions":[{"$":"GlobalVariableCondition","ComparisonGlobalVariableIndex":null,"ComparisonLocalVariableIndex":null,"Index":0,"Operand":4,"Value":"50","Metadata":null}],"IsDefaultSet":0,"Name":"Player is high level","Metadata":null}],"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Flow.SwitchConditionalCommand"}