Break Loop
Category: Flow
An event content that exits a repeating process between Loop and Loop End midway. It is typically used in combination with Conditional Branch in the form of "exit the loop when a condition is met".
Difference in role between Break Loop and Loop End
This event content and Loop End are similar, but their roles are opposite:
| Function | Behavior |
|---|---|
| Break Loop (this event content) | Jumps immediately after the corresponding Loop End (exits the loop) |
| Loop End | Returns immediately after the corresponding Loop (continues the loop) |
Use this event content when you want to exit a loop, and Loop End when you want to repeat.
Property list
This event content has no properties. It operates simply by adding it to the event content list.
Runtime behavior
When this event content is executed, the following processing is performed:
1. Search upward for the nearest "Loop"
Scanning upward from the position of this event content, it searches for the nearest Loop.
2. Forward-search for that loop's "Loop End"
It scans downward to find the Loop End corresponding to the found Loop.
3. Jump to immediately after Loop End
It jumps to the line immediately after the corresponding Loop End. This exits the loop and executes the subsequent processing.
4. Nest support (exits the nearest loop)
When Loop is nested, this event content exits only the nearest loop (= the inner loop). The outer loop continues.
If you want to exit both the inner and outer loops, you need to separately evaluate a condition in the outer loop as well and execute this event content.
5. Can be used from within a conditional branch
This event content can be executed from within Conditional Branch (Else / End If) too. The runtime correctly finds the upward loop even inside branch structures.
6. When no Loop is found (error case)
If no corresponding Loop is found, a warning log is output and processing silently proceeds to the next event content (not treated as an error).
[Event] Break Loop: no enclosing Loop found at line N, jumping to next lineNormally this is prevented by validation at editor save time, but it serves as a safety measure in case event data is corrupted.
Save-time check
When saving an event in the editor, if this event content is placed outside of Loop, the following error is reported:
line N: Break Loop が Loop 外で存在This event content must be placed inside Loop ~ Loop End. However, within a loop, it can be placed at any depth, including inside Conditional Branch.
Typical usage flows
Flow 1: Conditional termination (while-style)
Repeat until HP reaches 0:
- Loop
- Conditional Branch (Formula
MEM_0.HP.NOW <= 0) - Break Loop (this event content) ← exits when HP reaches 0
- End If
- (damage processing)
- Show Text ← waiting type
- Loop End
- Show Text ← "Finally fell..." (after exiting the loop)
Flow 2: Counter-based loop (for-style)
Repeat 5 times:
- Assign Variable (counter = 0)
- Loop
- Conditional Branch (Formula
{counter} >= 5) - Break Loop (this event content) ← exits after 5 iterations
- End If
- Show Text ← message inside the loop
- Assign Variable (counter + 1)
- Loop End
Flow 3: Menu loop (exit by user operation)
Display the menu until "Quit" is selected:
- Loop
- Show Window
- Add Choice × 3 (Buy / Sell / Quit)
- Show Selection Window
- Conditional Branch (Formula
{selected} == 2) - Break Loop (this event content) ← exits when "Quit" is selected
- End If
- (buy/sell processing)
- Loop End
Flow 4: Nested loops, exit only inner
The outer continues even after exiting the inner loop:
- Loop ← outer
- Loop ← inner
- Conditional Branch (inner exit condition)
- Break Loop (this event content) ← exits only the inner
- End If
- Wait (time 0.1)
- Loop End ← inner
- (outer processing continues)
- Conditional Branch (outer exit condition)
- Break Loop (this event content) ← also exits the outer (as needed)
- End If
- Loop End ← outer
Flow 5: Exit on multiple conditions
With multiple termination conditions, evaluate like Else-if:
- Loop
- Conditional Branch (Formula
MEM_0.HP.NOW <= 0) - Break Loop (this event content) ← exits at HP 0
- End If
- Conditional Branch (Formula
{counter} >= 10) - Break Loop (this event content) ← exits after 10 iterations
- End If
- (loop body processing)
- Assign Variable (counter + 1)
- Loop End
Flow 6: Forced exit (unconditional Break)
Exit immediately without condition evaluation (rare use case but possible):
- Loop
- Show Text ← waiting type
- Break Loop (this event content) ← unconditional exit (= executed only once)
- Loop End
(This structure makes the loop unnecessary in the first place, so normally combine with a conditional check)
Typical combinations
For the overall picture, see Combination pattern collection.
Conditional termination loop (while-style)
The standard pattern of exiting the loop when a condition is met:
- Loop
- Conditional Branch (termination condition)
- Break Loop (this event content)
- End If
- (loop body)
- Loop End
Counter-based loop (for-style)
Repeat a specified number of times:
- Assign Variable (variable initialization)
- Loop
- Conditional Branch (counter condition)
- Break Loop (this event content)
- End If
- (loop body)
- Assign Variable (counter update)
- Loop End
Menu loop
Exit by user operation:
- Loop
- Show Selection Window
- Conditional Branch (exit selection check)
- Break Loop (this event content)
- End If
- (selection processing)
- Loop End
Break inside nest
Exit only the nearest loop:
- Loop ← outer
- Loop ← inner
- Conditional Branch
- Break Loop (this event content) ← exits only the inner
- End If
- (inner processing)
- Loop End ← inner
- (outer processing)
- Loop End ← outer
Related event content
| Related event content | Purpose |
|---|---|
| Loop | The starting point of the loop that this event content belongs to |
| Loop End | Opposite role to this event content (continuation vs. exit) |
| Conditional Branch | Frequently used together for exit condition evaluation |
| Else | Used with conditional branch |
| End If | Used with conditional branch |
Related pages
| Page | Related content |
|---|---|
| Formula Reference | Formulas for exit conditions |
| Variable tab | Variable definitions for counters and exit flags |
| Event content index | List of all event contents |
Notes
Place inside the loop
This event content must be placed inside Loop ~ Loop End. Placing it outside the loop reports an error when saving in the editor.
Exits only the nearest loop
When nested, this event content exits only the nearest loop (inner loop). The outer loop continues. If you want to exit multiple layers of loops at once, separately evaluate a condition in the outer loop and execute this event content.
Can also be used from within a conditional branch
This event content can be placed inside branch structures like Conditional Branch. The runtime ignores the branch structure and correctly searches upward for the loop.
Beware of confusion with Loop End
- Break Loop (this event content): Exits the loop (jumps to immediately after Loop End)
- Loop End: Continues the loop (returns to immediately after Loop)
The names are similar but their roles are opposite. Be careful not to confuse them.
Silent when no corresponding loop is found
If no corresponding Loop is found, a warning log is output and processing proceeds to the next event content without doing anything (silent fallback). This case does not occur if validated by the editor, but it is a safety measure for cases such as corrupted data.
Normally used in combination with a conditional check
Using this event content alone causes the loop to enter and exit immediately, making the loop meaningless. Normally combine it with Conditional Branch to exit only when a specific condition is met.
