Console Client
Documentation
Dashboard
Everyday Tools

Macro steps: variables, conditions and loops

Store values in variables, branch with If and Switch, wait for a condition, repeat a range of steps, and run one macro inside another.

Variables

Each run has its own set of variables. They keep their values across the loops of that run and start empty when you press Run again. Use a variable anywhere a step takes text with %var:NAME%, or a field of it with %var:NAME.field%.

StepWhat it stores
Set VariableA value you type, with tokens expanded. Store it as text, a number, or true/false so comparisons behave. Names use letters, digits, and underscores.
Counter / IncrementAdds a number to a variable each time it runs, with an initial value for the first run. Negative numbers count down.
Persist VariableSaves a variable to that account’s own file, or loads it back with a default when nothing was saved. Load at the start and save at the end to keep a lifetime counter across runs and reconnects.
Read SlotWhat a slot holds: empty, name, displayName, count, customName, lore, and loreText. Test %var:order.loreText% for a price, for example.
Find Slotslot (or -1 when missing), found, name, and count.
Save PositionThe account’s x, y, and z.

If / Branch

If / Branch tests one thing and then continues, skips a number of following steps, or aborts the run, with a separate choice for true and for false.

Test sourceWhat is compared
VariableA variable or a field of it, using the dotted path.
Item field in a slotThe name, display name, count, custom name, or lore of a slot.
Bot health, Bot foodA number from 0 to 20.
Total inventory count of an itemHow many of a named item the account carries in total.
A container/GUI is opentrue or false.
World day/night, World time tickThe word day or night, or the tick from 0 to 23999.
A server dialog is open, dialog title, dialog bodyJava 1.21.6 and newer only.

Operators are equals, not equals, less than, less or equal, greater than, greater or equal, contains, starts with, and a regular expression. Numbers compare as numbers when both sides look numeric. The compare value accepts tokens.

Wait Until Condition and Switch

StepSettings
Wait Until ConditionThe same test picker, checked every poll interval (50 to 5000 ms) until it becomes true or the timeout passes (up to one hour). On timeout, continue or stop this macro.
Switch / Match CasesCompares one value against up to six cases. The first matching case decides: continue, skip a number of steps, or abort, and a default action covers no match. Case values accept tokens; blank cases are ignored.

Repeat, For Each and Try / Catch

These three work on a range of step numbers, counted from 1 as shown on the cards. Reordering steps updates the ranges for you.

StepSettings
Repeat StepsRuns steps from one number to another again, 1 to 500 times. A Repeat, For Each, or Try / Catch inside the range is skipped rather than nested.
For Each ItemRuns a range once per matching inventory slot, exposing the current item as a variable (default item). Filter by item name, limit the slot range, cap the iterations (1 to 500), or walk the open menu instead of the player inventory.
Try / CatchRuns the try range and, if any step in it fails, runs the catch range instead, then carries on after the Try / Catch step. An Abort Run inside is not caught.

Abort, Run Macro and errors

Step or settingBehaviour
Abort RunEnds this run cleanly. With loops, the next loop starts after the Between loops delay.
Run MacroRuns another saved macro’s steps at this point, 1 to 100 times, sharing the same variables in both directions. Only the other macro’s steps run; its own loop and trigger settings are ignored. Up to five levels deep.
Stop on errorOn by default: a step that fails ends the run. Turn it off and the failure is logged and the next step runs. Dig Down stopping at lava, a Wait timing out with Continue, and a missing Hold Item without the abort option are normal ends, not errors.

Example: count runs across restarts

  1. Load the counter

    Persist Variable, action Load, variable runs, default 0 as a number.

  2. Do the work

    The steps you want counted.

  3. Count and save

    Counter / Increment on runs, then Persist Variable with action Save.

  4. Show it

    Log Message with Run %var:runs% done, or a Discord Alert with the same text.

Need a hand?

Check the troubleshooting guide or return to all guides.