Variables, Functions & Flow Control

← Back to all categories
What is a variable? How do I use variables in nodes?All

A variable is a "named box" used to store data at runtime (such as the result coordinates of an image search, OCR-recognized text, a counter, and so on).

How to use one:

  1. Define the variable in the "Variables" tab (Ctrl+3): give it a name (e.g. count), choose a type (string/number/boolean), and set a default value
  2. Write to the variable in a node: e.g. a "Set Variable" node, or the "Result Variable" field of a Find Image node
  3. Read the variable in a node: e.g. reference it in a condition for comparison, or insert its value in an "Input Text" node

Typical usage:

  • The result of an image search is automatically stored in a variable (e.g. result), including coordinates and confidence
  • Use a "Set Variable" node as a counter: count + 1 on each loop iteration
  • Reference a variable in an "Input Text" node for dynamic input
How do I use the "Condition" node? What do On Success / On Failure / Custom Condition mean?All

Conditions let your script "take different paths depending on the situation". Every node can have an execution condition set (at the bottom of the node configuration):

  • Unconditional (default) — runs no matter what happened before
  • On Success — runs only if the previous node succeeded. E.g. image found → then click
  • On Failure — runs only if the previous node failed. E.g. image not found → take a fallback path
  • Custom Condition — write an expression; it runs only when the expression is true. E.g. count >= 5 (only run after more than 5 loop iterations)

How are "success/failure" defined?

  • Find Image: found = success, not found = failure
  • OCR Compare: text matches = success, doesn't match = failure
  • Wait for Change: change detected = success, timed out = failure
  • Wait / Click / Log: always succeeds
How many modes does the "Loop" node have? How do I use them?All

The Loop node is a container — drag other nodes into it and they'll be executed repeatedly. Three modes:

  • Fixed count — loop N times. E.g. click 10 times → set the count to 10.
  • Infinite loop — repeats forever until the script is stopped manually. E.g. continuously monitoring a health bar, continuous farming.
  • Iterate array — takes each element of an array in turn and executes. E.g. click each button in a list one by one.

How to use:

  1. Add a "Loop" node
  2. Double-click to configure it, choosing the loop mode and parameters
  3. Drag the nodes to repeat into the loop container (they'll be shown indented)

Tip: in an infinite loop, we recommend adding a short "Wait" node (e.g. 100ms) to avoid excessive CPU usage.

What is a function? When should I turn a sequence into a function?All

A function "packages" a group of nodes into a reusable module. Define it once, then call it multiple times from the main flow.

When to use one?

  • The same sequence appears 2 or more times in your flow → make it a function to avoid duplication
  • A sequence has an independent meaning (e.g. "return to town", "reload ammo", "turn the page") → making it a function makes the flow clearer
  • You want to call a sequence from a custom action → it must be a function first

How to use:

  1. Create a function in the "Functions" tab (Ctrl+5) and edit its internal nodes
  2. Add a "Call Function" node in the main flow and select the function to call
  3. Functions can take parameters, letting you pass different values at each call

Functions can call each other, and they can access global variables.

What is an expression? Where can I use expressions?All

An expression is a snippet of Lua code that produces a value when run. It lets you perform calculations, concatenation, comparisons, and other flexible operations.

Places where you can use expressions:

  • Custom conditions in a Condition: count >= 10 and hp < 30
  • Set Variable with "Expression" checked: count + 1, name .. "_done"
  • Log Output with "Expression" checked: "Loop #" .. count
  • Wait time: math.random(500, 1500) (random wait)

Common syntax:

  • Arithmetic: a + b, a * 2, a % 3
  • String concatenation: "hello" .. name
  • Comparison: x > 100, name == "test"
  • Logic: a and b, a or b, not a

When "Expression" is not checked, the input field's content is treated as plain text/a number.