Skip to content

Loop ​

Category: Flow Control (Flow)

A marker indicating the starting point of iterative (loop) processing. The processing written between this event content and Loop End (Loop End) is executed repeatedly until a Break Loop (Break Loop) or a conditional termination occurs.

Always place with Loop End as a pair

When using this event content, always place a corresponding Loop End (Loop End). Structure of placement:

Loop (this event content)
    (processing executed repeatedly)
    [Conditional Branch → Break Loop for termination check]
Loop End (Loop End)       ← required

To exit the loop midway, combine Conditional Branch (Conditional Branch) + Break Loop (Break Loop).

Always include "wait-type processing" in the loop to avoid infinite loops

At editor save time, if none of the following "wait-type processing" is included in the loop, an error is reported. This is validation to prevent an infinite loop without waiting that would freeze the game.

List of wait-type processing:

Include at least one of these in the loop.

Property List ​

This event content has no properties. It operates simply by being added to the event content list.

Runtime Behavior ​

This event content is an entry marker. At runtime, it does nothing and immediately proceeds to the next event content.

1. Reaching the entry ​

When this event content is reached: Does nothing and starts executing the next event content.

2. Execution of the loop body ​

The event contents between this and Loop End (Loop End) are executed sequentially.

3. Reaching Loop End ​

When the Loop End (Loop End) at the end of the loop body is reached, the corresponding instance of this event content is found, and processing jumps to the line immediately after it to continue the loop. One frame is yielded before resumption, preventing stack overflow.

4. Methods for terminating the loop ​

There are two methods for terminating the loop:

5. Nesting support ​

This event content can be nested. The correspondence (Loop ↔ Loop End) between inner and outer loops is automatically determined correctly (depth tracking).

Break Loop (Break Loop) exits the nearest instance of this event content (exits the inner loop while remaining in the outer loop).

Typical Usage Flows ​

Flow 1: Repetition using a counter ​

Repeat a specified number of times using a variable:

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

Flow 2: Choice-based menu loop ​

Repeatedly display the menu until a selection is made:

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

Flow 3: Condition-based loop ​

Repeat until a certain state is reached:

  1. Loop (this event content)
  2. Conditional Branch (Conditional Branch) (Formula MEM_0.HP.NOW <= 0)
  3. Break Loop (Break Loop) ← exits when HP reaches 0
  4. End If (End If)
  5. (damage processing)
  6. Show Text (Show Text) ← damage line
  7. Loop End (Loop End)

Flow 4: Nested loops ​

Multi-level loops (3 × 3 grid processing, etc.):

  1. Assign Variable (Assign Variable) (row = 0)
  2. Loop (this event content) ← outer (row)
  3. Assign Variable (Assign Variable) (col = 0)
  4. Loop (this event content) ← inner (col)
  5. (per-col processing)
  6. Assign Variable (Assign Variable) (col + 1)
  7. Conditional Branch (Conditional Branch) (Formula {col} >= 3)
  8. Break Loop (Break Loop) ← inner Break
  9. End If (End If)
  10. Loop End (Loop End) ← inner Loop End
  11. Assign Variable (Assign Variable) (row + 1)
  12. Conditional Branch (Conditional Branch) (Formula {row} >= 3)
  13. Break Loop (Break Loop) ← outer Break
  14. End If (End If)
  15. Loop End (Loop End) ← outer Loop End

Flow 5: Infinite loop for demo playback ​

Continuously play title screen background demo:

  1. Loop (this event content)
  2. Show Image (Show Image) (number 0, image 1)
  3. Wait (Wait) (time 3.0) ← including wait-type avoids infinite synchronous loop
  4. Show Image (Show Image) (number 0, image 2)
  5. Wait (Wait) (time 3.0)
  6. Loop End (Loop End)

(Since the title screen transitions on user input, an infinite loop is not a problem in terms of game progression)

Flow 6: Sound playback → selection → repetition ​

Repeated check while playing sound:

  1. Play Sound (Play Sound) (BGM)
  2. Loop (this event content)
  3. Show Selection Window (Show Selection Window) ← wait-type
  4. (processing of selection result)
  5. Loop End (Loop End)

Typical Combinations ​

See Combination Pattern Collection for the overall picture.

Conditional termination loop (while-like) ​

Repeat until condition is met:

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

Counter-based loop (for-like) ​

Repeat specified number of times:

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

Repeat menu until user selects "quit":

  1. Loop (this event content)
  2. Show Selection Window (Show Selection Window)
  3. Conditional Branch (Conditional Branch) ("quit" check)
  4. Break Loop (Break Loop)
  5. End If (End If)
  6. (processing of each choice)
  7. Loop End (Loop End)

Nested loops (multi-level loops) ​

Matrix processing, etc.:

  1. Loop (this event content) ← outer
  2. Loop (this event content) ← inner
  3. (processing)
  4. (inner termination check + Break Loop)
  5. Loop End (Loop End) ← inner
  6. (outer termination check + Break Loop)
  7. Loop End (Loop End) ← outer
Related Event ContentPurpose
Loop End (Loop End)Pair with this event content (end of loop body, required pair)
Break Loop (Break Loop)Exit the loop midway
Conditional Branch (Conditional Branch)Frequently used together for termination checks inside the loop
Else (Else)Used together with Conditional Branch
End If (End If)Used together with Conditional Branch
Wait (Wait)Representative example of wait-type processing inside loop
PageRelated Content
Formula ReferenceFormulas for loop termination checks
Variable TabDefinition of counter variables
Event Content ListList of all event contents

Notes ​

Loop End is required ​

When this event content is placed, always place a corresponding Loop End (Loop End). Without a corresponding pair, an error occurs at editor save time.

Infinite loop prevention (Important) ​

If this event content is used without including any wait-type processing (see the tip above for details) in the loop, an "infinite synchronous loop risk" error occurs at editor save time. This is validation to prevent the game from freezing in an infinite loop without waiting.

Be sure to include processing that takes 1 frame or more in the loop, such as Wait (Wait) or Show Text (Show Text).

Implement termination check yourself to exit the loop ​

This event content does not have a built-in loop termination function. You need to implement the termination check yourself with Conditional Branch (Conditional Branch) + Break Loop (Break Loop).

Nesting possible ​

This event content can be nested. An inner Break Loop exits only the inner loop (does not affect the outer loop).

Manually manage counter variables ​

There is no counter auto-management feature like for loops. Explicitly increment the counter with Assign Variable (Assign Variable).

As an entry marker, does nothing at runtime ​

This event content does nothing at runtime and immediately proceeds to the next event content. Its actual role is to serve as a marker indicating the "starting point of the loop" for the runtime to reference.