Skip to content
Bit Quirky Round Trip
Visual Scripting

Search documentation

All topics and APIs

Close returns focus to Search.

What are you looking for?

Try a common topic or a C# feature.

Browse the reference instead

Esc closes · Tab reaches results · Enter opens the focused link

v1.0.0
Menu

Operators and expressions

Place math, comparison, and logic nodes from the action menu and wire values through them.

Operator nodes turn values into new values. Math nodes work on numbers, comparison nodes answer yes or no, logic nodes combine yes-or-no answers, and Concat joins text.

Each operator is a node with inputs on the left and one Result pin on the right, colored like the value it produces: red for a comparison or logic answer, green for a number, pink for text. It has no white pins: it works out its answer at the moment a node on the white wire asks for it. You build a bigger calculation by wiring one operator’s Result into the next operator’s input, so the order of the math is the order of the wires.

Adding to a value is a read flowing through an ADD node and back into a SET node for the same value. That loop on the canvas is the whole of “add this to that”.

Reach for a math node when the game needs a number worked out: score from coins times points per coin, a speed scaled by a boost, a timer counting down. Reach for a comparison when a decision depends on a number or a reference: has the player collected enough coins, is health below zero, is this the same coin as before. Combine comparisons with And or Or when the decision needs more than one answer, such as “the door is locked or the level is complete”. Use Concat to build a message such as a score label.

Two more operators choose values. Conditional picks one of two values by a yes-or-no answer, such as a bonus score or a normal score. Null coalesce supplies a fallback when a value is missing, such as a default title when none was given.

An operator node produces a value and never runs on its own. So when you drag a white Exec pin onto empty canvas, the menu that opens leaves out the math, Concat, comparison, and logic rows. Place them by right-clicking empty canvas, then wire their Result into the node that uses it.

These are three separate methods in the sample, each using a different kind of result. None of these slides is an edit of the previous method.

Compare result types

Select a screenshot to enlarge it.

AddCoins reads Coins and Score through ADD and MULTIPLY nodes into SET nodes.
Figure 1. Calculate a number: AddCoins Green ADD and MULTIPLY results feed SET Value pins. The white exec path chooses when the stored totals change; the colored wires show how each new number is calculated.
ShouldRespawn returns the red result of LESS OR EQUAL applied to two green inputs.
Figure 2. Answer yes or no: ShouldRespawn The two inputs are numbers, but the result is bool. Its red wire goes to EXIT value: a comparison can return an answer without creating a BRANCH.
ChooseSprite wires IsUnlocked into SELECT condition and two sprite pills into its true and false inputs.
Figure 3. Choose a value: ChooseSprite SELECT chooses between _unlockedSprite and _lockedSprite. Its purple result fills one sprite local; it does not create two white execution paths.

Build and use operator results

  1. Place an operator

    On a method canvas that has a node needing a value (a SET node, a call node, or a yellow BRANCH node with an empty Condition pin), right-click empty canvas nearby and type the operation’s name, such as Add, Subtract, Multiply, Divide, or Modulo. Pick one.

    The AddScore entry and a Score SET node, with the existing ADD result feeding its Value pin.
    Clip: the pointer opens the canvas menu, searches for Add, and picks it; a new unconnected ADD appears beside the existing node. The Add row of the menu is highlighted while it is picked.
  2. Supply the operands

    Fill Left and Right. Drag a wire from a pill, a parameter pin, or another node’s result, or click beside the pin and type a number such as 5.

    Clip: the amount parameter is wired to both inputs of the new ADD; its pins and result turn green. The Left pin, then the Right pin, of the new ADD are highlighted while a wire is dropped on them.
  3. Add or remove an input

    To work on more than two values, click Add pin under the inputs of an Add, Subtract, Multiply, Divide, And, Or, or Concat node. Hover an input to show its remove icon, then click it to take the input away.

    Clip: Add pin creates a third input; hovering it reveals its remove icon, which is clicked to restore two inputs. The Add pin button, then the remove icon of the third input, are highlighted.
  4. Connect the result

    Drag from Result to the pin that needs the answer, such as the SET node’s Value.

    Clip: the new ADD result is dragged into the Value pin of the Score SET, replacing the previous wire. The new ADD's Result pin and the Score SET's Value pin are highlighted.
  5. Compare values

    For a yes-or-no answer, use Equals, Not equals, Less than, Less or equal, Greater than, or Greater or equal. Wire a comparison result into a BRANCH node’s Condition, into And or Or, or into a return value as shown here.

    In a separate CompareEnum method, a purple state input and Patrolling dropdown feed EQUALS; its red result goes to EXIT value.
    The Compare method wires score and the literal 5 through GREATER OR EQUAL into EXIT value.
  6. Join text

    To build text, use Concat. Wire text or another value, such as a label and a score, into either side.

    The separate Label method sends a score and a text literal through CONCAT into EXIT value.
  7. Choose a value or fallback

    To pick between two values, use Conditional. Wire the deciding answer and candidate values into its pins and its Result into the node that uses it. To supply a fallback for a missing value, use Null coalesce.

    The separate Choose method wires a bool and two strings into SELECT and sends the selected value to EXIT.
    The Fallback method connects title and the Untitled literal to a null coalesce node, whose result goes to EXIT value.
  8. Change an operation

    To swap a math node for a different operation, right-click the node, choose Change operator, and pick the operation.

    Clip: the Operator picker is opened for this demonstration, then the pointer chooses Subtract and the ADD node changes to SUBTRACT. The Subtract row of the picker is highlighted.
  9. Compile the connected result

    Press Compile in the toolbar.

    The whole window just before Compile: amount is wired to both inputs of the new ADD, whose result feeds the Value pin of the Score SET. The gold Compile button in the toolbar is highlighted with an arrow pointing at it.
    After Compile and reload the whole window shows the saved AddScore graph: amount wired to both ADD inputs, with its result connected to the Value pin of the Score SET. Compile is gray again and is highlighted with an arrow pointing at it.

A call or read that should quietly do nothing when its object is missing shows a small shield mark beside its Target pin, as PlayCoin does on the _audio wire in the CollectCoin visual script of the Platformer sample.

If you also work in C#, this is what is written into the script. The Coins, Score, and _audio lines come from the Platformer sample, gathered here in an AddBonusCoins method on ScoreCounter whose inputs feed the two var lines, short illustrations of Null coalesce and Conditional.

A read flowing through an operation back into a SET of the same value keeps its short += spelling in the script while it still reads that same value. A new operation built on the canvas is written out in full. Brackets are added wherever the math needs them, and wherever the script must read back as the nodes you built: two MULTIPLY nodes, one feeding the other, are written (a * b) * c, while one MULTIPLY with three inputs is written a * b * c.

When it goes wrong

SymptomCheckFix
An operation is missing from Change operatorLook at the colors of the wires feeding left and right.Wire values of a type that operation accepts, then open Change operator again.
Compile reports a missing operandLook for a hollow input pin on an operator node.Wire or type a value into every hollow pin, or remove an input you added and did not need.
An add-to-value loop is written out in fullFollow the read into the operator: is it the same variable the SET node writes?Wire a read of that same variable back in if you meant add to it.
Full-size image