Logic and Math
Branching, looping, comparison and arithmetic. These are the nodes that give a script its shape.
Branching
Branch
The if node.
| Execution in | unnamed |
| Execution out | True, False |
| Data in | Condition — Bool (also settable as a constant) |
CompareExec
Compares two values and branches in one node. Prefer this over a separate
Compare feeding a Branch.
| Title | {A} {Operator} {B} |
| Execution in | unnamed |
| Execution out | True, False |
| Data in | A, B — Any |
| Property | Operator — Equal, NotEqual, Less, LessEqual, Greater, GreaterEqual |
SwitchInt64 / SwitchString
Multi-way branch. Add entries to the Cases property and the node grows one
execution output per case.
| SwitchInt64 | SwitchString | |
|---|---|---|
| Title | Switch | Switch |
| Execution in | unnamed | unnamed |
| Execution out | one per case, plus Default | one per case, plus Default |
| Data in | Value — Int64, required | Value — HashedString, required |
| Property | Cases — up to 16 numbers | Cases — up to 16 strings |
Comparison and boolean logic
All of these are data nodes with no execution pins.
| Node | Title | Data in | Data out |
|---|---|---|---|
Compare | {A} {Operator} {B} | A, B — Any | "" — Bool |
And | {A} AND {B} | A, B — Bool | "" — Bool |
Or | {A} OR {B} | A, B — Bool | "" — Bool |
Not | NOT {A} | A — Bool | "" — Bool |
IsValid | — | "" — Any, required | "" — Bool |
Select | {Condition} ? {A} : {B} | Condition — Bool; A, B — Any | "" — Any |
Compare takes the same Operator property as CompareExec.
IsValid is the one to remember: object and component references can
go stale when something is deleted. Check before you use a reference you looked up
earlier, particularly across a coroutine wait.
Select chooses between two values without splitting execution. Use
it when both branches would otherwise do the same thing with a different number.
Loops
Every loop node has two execution outputs: LoopBody runs once per iteration,
Completed runs once when the loop finishes.
ForLoop
| Title | ForLoop [{FirstIndex}..{LastIndex}] |
| Execution in | unnamed |
| Execution out | LoopBody, Completed |
| Data in | FirstIndex, LastIndex — Int |
| Data out | Index — Int |
The range includes both ends: 0 to 8 runs nine times.
WhileLoop
| Execution in | unnamed |
| Execution out | LoopBody, Completed |
| Data in | Condition — Bool |
The condition is re-evaluated every iteration, all within a single frame. If it
never becomes false the frame never ends. Put a Yield in the loop body
if there is any chance of a long run.
ForEachLoop / ReverseForEachLoop
Identical apart from direction.
| Execution in | unnamed |
| Execution out | LoopBody, Completed |
| Data in | Array — Array |
| Data out | Element — Variant, Index — Int |
Element is a Variant, so you will often need
Variant_ConvertTo to use it.
Break
Leaves the innermost loop immediately and continues from its Completed pin.
| Execution in | unnamed |
| Everything else | none |
Arithmetic
Four data nodes, no execution pins, all working on numbers and vectors alike.
| Node | Title | Data in | Data out |
|---|---|---|---|
Add | {A} + {B} | A, B — Any | "" — Any |
Subtract | {A} - {B} | A, B — Any | "" — Any |
Multiply | {A} * {B} | A, B — Any | "" — Any |
Divide | {A} / {B} | A, B — Any | "" — Any |
The output type is worked out from the inputs. Leave an input unconnected to type a constant into the property grid — that is how the jump pad multiplies its force by a fixed scale.
Expression
A written formula, for when a chain of maths nodes would be unreadable.
| Title | {Expression} |
| Execution | none |
| Data in | one pin per entry in Inputs |
| Data out | one pin per entry in Outputs |
| Properties | Expression — the formula; Inputs and Outputs — up to 16 each, named and typed |
Each input and output is declared with a name and a type (Int, Float, Vector3 or Color), and the names become the variables in your formula.
See Also
- Key Nodes
- Coroutines — for loops that need to span frames