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%.
| Step | What it stores |
|---|---|
| Set Variable | A 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 / Increment | Adds a number to a variable each time it runs, with an initial value for the first run. Negative numbers count down. |
| Persist Variable | Saves 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 Slot | What a slot holds: empty, name, displayName, count, customName, lore, and loreText. Test %var:order.loreText% for a price, for example. |
| Find Slot | slot (or -1 when missing), found, name, and count. |
| Save Position | The 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 source | What is compared |
|---|---|
| Variable | A variable or a field of it, using the dotted path. |
| Item field in a slot | The name, display name, count, custom name, or lore of a slot. |
| Bot health, Bot food | A number from 0 to 20. |
| Total inventory count of an item | How many of a named item the account carries in total. |
| A container/GUI is open | true or false. |
| World day/night, World time tick | The word day or night, or the tick from 0 to 23999. |
| A server dialog is open, dialog title, dialog body | Java 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
| Step | Settings |
|---|---|
| Wait Until Condition | The 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 Cases | Compares 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.
| Step | Settings |
|---|---|
| Repeat Steps | Runs 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 Item | Runs 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 / Catch | Runs 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 setting | Behaviour |
|---|---|
| Abort Run | Ends this run cleanly. With loops, the next loop starts after the Between loops delay. |
| Run Macro | Runs 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 error | On 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
Load the counter
Persist Variable, action Load, variable
runs, default 0 as a number.Do the work
The steps you want counted.
Count and save
Counter / Increment on
runs, then Persist Variable with action Save.Show it
Log Message with
Run %var:runs% done, or a Discord Alert with the same text.
Check the troubleshooting guide or return to all guides.