Branch By Value
- Group
- Variables
- In the node menu
- Variables › Branch By Value
- Where it can be used
- Scheme graphs
What it does
Section titled “What it does”Branch By Value looks at one variable and takes the output of the first case that has its value. When no case does, it takes Otherwise. Each case has its own output, so one node replaces a chain of yes-or-no checks.
The cases are looked at from top to bottom.
Example
Section titled “Example”There is no demo scheme with this node, so there is no card. The card of the node starts with Branches by and the variable. Under it come up to four lines, each a value, an arrow and the name of that case’s output. With more than four cases, a last line says how many more there are.
When to use it
Section titled “When to use it”Use it when one variable decides between several ways: a choice the player made, a stage number, a named choice of an Enum variable. See Fewer nodes for the same graph.
Use Compare Variable instead for a single yes-or-no question or for a range, such as at least a value.
Good to know
Section titled “Good to know”- Only Text, whole-number, Bool and Enum variables are offered.
- Text must match exactly. Upper and lower case count.
- A case’s output carries its name. Without a name it carries the value. A case for False, for 0 or for empty text gets the output name Case and its number; the card line still shows the value.
- A case with the same value as an earlier case never runs. The inspector says so under Reads as.
- With no cases, the inspector says under Reads as to add values. Everything then goes through Otherwise.
- When the variable is not there, or a case cannot be compared, the flow stops at the node.
Settings
Section titled “Settings”| Label | Draft key | Type | Default | Shown if, tooltip and notes |
|---|---|---|---|---|
| Variable | Variable | VariableRef [String, Integer, Bool, Enum] | none | The variable to look at. Text, whole numbers, yes/no values and named choices can be branched on. |
| Cases | Cases | list of ValueCase | [] | The values to tell apart. Each case has its own output; the first case that has the variable's value runs. |
Cases: the settings of each one
| Label | Draft key | Type | Default | Shown if, tooltip and notes |
|---|---|---|---|---|
| draft only | Key | text | "" |
|
| Value | Value | VariableValue | not in the data | |
| Label | Label | text | "" | The name shown on this case's output. Empty: the value itself. |
Outputs
Section titled “Outputs”- Otherwise
In a draft
Section titled “In a draft”"type""Branch By Value""set"keysVariable,Cases"then"keys"<case Key>","otherwise"
"<alias>": { "type": "Branch By Value", "then": { "<case Key>": "<alias>", "otherwise": "<alias>" }}