Skip to content

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:

FunctionBehavior
Break Loop (this event content)Jumps immediately after the corresponding Loop End (exits the loop)
Loop EndReturns 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 line

Normally 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:

  1. Loop
  2. Conditional Branch (Formula MEM_0.HP.NOW <= 0)
  3. Break Loop (this event content) ← exits when HP reaches 0
  4. End If
  5. (damage processing)
  6. Show Text ← waiting type
  7. Loop End
  8. Show Text ← "Finally fell..." (after exiting the loop)

Flow 2: Counter-based loop (for-style) ​

Repeat 5 times:

  1. Assign Variable (counter = 0)
  2. Loop
  3. Conditional Branch (Formula {counter} >= 5)
  4. Break Loop (this event content) ← exits after 5 iterations
  5. End If
  6. Show Text ← message inside the loop
  7. Assign Variable (counter + 1)
  8. Loop End

Flow 3: Menu loop (exit by user operation) ​

Display the menu until "Quit" is selected:

  1. Loop
  2. Show Window
  3. Add Choice × 3 (Buy / Sell / Quit)
  4. Show Selection Window
  5. Conditional Branch (Formula {selected} == 2)
  6. Break Loop (this event content) ← exits when "Quit" is selected
  7. End If
  8. (buy/sell processing)
  9. Loop End

Flow 4: Nested loops, exit only inner ​

The outer continues even after exiting the inner loop:

  1. Loop ← outer
  2. Loop ← inner
  3. Conditional Branch (inner exit condition)
  4. Break Loop (this event content) ← exits only the inner
  5. End If
  6. Wait (time 0.1)
  7. Loop End ← inner
  8. (outer processing continues)
  9. Conditional Branch (outer exit condition)
  10. Break Loop (this event content) ← also exits the outer (as needed)
  11. End If
  12. Loop End ← outer

Flow 5: Exit on multiple conditions ​

With multiple termination conditions, evaluate like Else-if:

  1. Loop
  2. Conditional Branch (Formula MEM_0.HP.NOW <= 0)
  3. Break Loop (this event content) ← exits at HP 0
  4. End If
  5. Conditional Branch (Formula {counter} >= 10)
  6. Break Loop (this event content) ← exits after 10 iterations
  7. End If
  8. (loop body processing)
  9. Assign Variable (counter + 1)
  10. Loop End

Flow 6: Forced exit (unconditional Break) ​

Exit immediately without condition evaluation (rare use case but possible):

  1. Loop
  2. Show Text ← waiting type
  3. Break Loop (this event content) ← unconditional exit (= executed only once)
  4. 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:

  1. Loop
  2. Conditional Branch (termination condition)
  3. Break Loop (this event content)
  4. End If
  5. (loop body)
  6. Loop End

Counter-based loop (for-style) ​

Repeat a specified number of times:

  1. Assign Variable (variable initialization)
  2. Loop
  3. Conditional Branch (counter condition)
  4. Break Loop (this event content)
  5. End If
  6. (loop body)
  7. Assign Variable (counter update)
  8. Loop End

Exit by user operation:

  1. Loop
  2. Show Selection Window
  3. Conditional Branch (exit selection check)
  4. Break Loop (this event content)
  5. End If
  6. (selection processing)
  7. Loop End

Break inside nest ​

Exit only the nearest loop:

  1. Loop ← outer
  2. Loop ← inner
  3. Conditional Branch
  4. Break Loop (this event content) ← exits only the inner
  5. End If
  6. (inner processing)
  7. Loop End ← inner
  8. (outer processing)
  9. Loop End ← outer
Related event contentPurpose
LoopThe starting point of the loop that this event content belongs to
Loop EndOpposite role to this event content (continuation vs. exit)
Conditional BranchFrequently used together for exit condition evaluation
ElseUsed with conditional branch
End IfUsed with conditional branch
PageRelated content
Formula ReferenceFormulas for exit conditions
Variable tabVariable definitions for counters and exit flags
Event content indexList 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.