Break a while loop with a condition
Break an infinite loop
The while: command continuously repeats its child commands while its criteria remains true.
This example is an infinite loop that will break with 25% probability (random(n) is a random number from 0 to n inclusive). The loop repeats until isLooping is false.
At the end, the counter value shows how many times it looped, which will be different each time it runs.
start:
set:
isLooping@bool: yes
counter@int: 0
while/exampleLoop:
if@bool: {{isLooping}}
do:
set:
counter@int: {{counter + 1}}
isLooping@bool: {{3 != random(3)}}Loops like this can be used around an await: block to repeat an interaction until aborted by the user.