Assign Variable
Category: Variable
Event content that assigns a value to a variable. Forms the basis of every situation involving variables in game progression, such as updating counters, toggling flags ON/OFF, saving user input, and recording calculation results.
Variables must be defined beforehand in the "Variable tab"
Only variables defined in advance in the editor's Variable tab can be assigned to by this event content. To use one, first create a variable ID in the Variable tab.
There are 2 assignment modes
This event content has 2 assignment modes, switched by the "Assign calculation result" checkbox:
| Mode | Behavior | Purpose |
|---|---|---|
| Assign calculation result ON | Evaluates Value as a formula, assigns the result (number) | Counter update, flag (1/0), saving calculation result |
| Assign calculation result OFF | Assigns the Value string as-is | Fixed text, holding player input results |
Property List
| Item (tscn label) | Input type | Description |
|---|---|---|
| Variable | Selection | Destination variable (selected from those defined in the Variable tab) |
| Value | Formula or string | Value to assign (interpretation changes based on Assign calculation result ON/OFF) |
| Assign calculation result | Checkbox | ON = evaluate Value as a formula, OFF = treat as a string |
Property Details
Variable
Select the destination variable from the list defined in the Variable tab.
- Dropdown: select from the IDs of all variables created in the Variable tab
- Variables not defined in the Variable tab cannot be assigned to
Cross-tab realtime update (2026-09-09)
When a variable is added/removed in the Variable tab, the dropdown in this event content reflects it instantly.
Deleted variables show a warning
If a previously set variable is later deleted in the Variable tab, the corresponding ID is displayed with an Error icon in the dropdown. Running this state at runtime outputs a *** WARNING : Variable is missing. : <variable name> log, and the assignment is skipped (not an error).
Value
Specify the value to assign to the variable. The interpretation of the input field switches based on the Assign calculation result property.
When Assign calculation result is ON
Evaluated as a formula. The formula can use variable expansion ({other variable}) and references (such as USER.STR.MAX).
Examples:
0-> assigns the number0to the variable (flag reset)1-> assigns the number1to the variable (flag set){counter} + 1-> increments the counter by 1{counter} * 2-> doubles the counterMEM_0.LEVEL.NOW-> assigns the level of the leading memberPARTY.GOLD / 10-> assigns 1/10 of the gold
When Assign calculation result is OFF
Assigns the entered string as-is to the variable. No formula evaluation is performed.
Examples:
Hello-> assigns the string "Hello" to the variableyes-> assigns the string "yes" to the variable{var_1}-> assigns the string "{var_1}" to the variable as-is (not expanded)
Assign calculation result
Checkbox that switches the interpretation mode of Value.
- ON: evaluates Value as a formula and assigns the result (number)
- OFF: assigns the input text of Value as-is as a string
Variable type is determined at assignment time
Assigning with Assign calculation result ON makes the variable type number (float), and assigning with OFF makes it a string. Assigning to the same variable with 2 different modes switches the type with the later assignment.
Runtime Behavior
When this event content runs, the following processing occurs:
1. Variable existence check
Checks whether the specified variable exists in the in-game variable data.
- Does not exist: outputs
*** WARNING : Variable is missing. : <variable name>log and silently proceeds to the next event content without doing anything - Exists: proceeds to the assignment process
2. Branching by assignment mode
Assign calculation result ON (is_calc=true)
Formula.replace_all()expands variable expansions and references within ValueFormula.calc()evaluates the formula- The result (number) is assigned to the variable
Assign calculation result OFF (is_calc=false)
Assigns the input text of Value as-is to the variable (no formula evaluation performed).
3. Proceed to the next event content
Once the assignment process completes, immediately proceeds to the next event content.
Typical Usage Flows
Flow 1: Counter increment
Increment the variable counter by 1:
- Assign Variable (this event content)
- Variable:
counter - Value:
{counter} + 1 - Assign calculation result: ON
- Variable:
Flow 2: Flag set / reset
Set a flag (assign 1):
- Assign Variable (this event content)
- Variable:
flag_quest_started - Value:
1 - Assign calculation result: ON
- Variable:
Reset a flag (assign 0):
- Assign Variable (this event content)
- Variable:
flag_quest_started - Value:
0 - Assign calculation result: ON
- Variable:
Flow 3: Save party gold to a variable
Record a value you want to reference later:
- Assign Variable (this event content)
- Variable:
gold_snapshot - Value:
PARTY.GOLD - Assign calculation result: ON
- Variable:
- (An event where gold may change due to some processing)
- Conditional Branch (Formula
PARTY.GOLD < {gold_snapshot}) - Show Text <- "The gold has decreased!"
- End If
Flow 4: String assignment (fixed text)
Assign an NPC name to a variable:
- Assign Variable (this event content)
- Variable:
last_npc_name - Value:
Alice - Assign calculation result: OFF
- Variable:
- Show Text <- "I met {last_npc_name}"
Flow 5: Value switching based on condition
Assign different values based on HP remaining:
- Conditional Branch (Formula
MEM_0.HP.RATE >= 0.5) - Assign Variable (this event content) (variable
status, valuegood, calculation result OFF) - Else
- Assign Variable (this event content) (variable
status, valuebad, calculation result OFF) - End If
Flow 6: Loop with counter
Counter management for looping:
- Assign Variable (this event content) (variable
i, value0, calculation result ON) <- initialization - Loop
- Conditional Branch (Formula
{i} >= 5) - Break Loop
- End If
- Show Text <- loop processing
- Assign Variable (this event content) (variable
i, value{i} + 1, calculation result ON) <- increment - Loop End
Flow 7: Complex calculation result assignment
Assign a value calculated from multiple parameters:
- Assign Variable (this event content)
- Variable:
battle_strength - Value:
(MEM_0.STR.MAX + MEM_0.INT.MAX) * MEM_0.LEVEL.NOW / 10 - Assign calculation result: ON
- Variable:
Flow 8: Game statistics recording
Count the number of plays:
- Assign Variable (this event content) (variable
play_count, value{play_count} + 1, calculation result ON)
Typical Combinations
For the big picture, see Combination Pattern Collection.
Counter management
Initialize -> increment in loop -> terminate by condition check:
- Assign Variable (this event content) (initialization,
i= 0) - Loop
- Conditional Branch (
{i} >= N) + Break Loop - (Loop processing)
- Assign Variable (this event content) (increment,
{i} + 1) - Loop End
Flag management
Flag set -> reference in branch:
- Assign Variable (this event content) (
flag_X= 1) - ... another event ...
- Conditional Branch (
{flag_X} == 1) - (Processing)
- End If
Snapshot + comparison
State save -> change check:
- Assign Variable (this event content) (snapshot save)
- (State change event)
- Conditional Branch (change check)
Processing selection results
Reflect selection in a variable:
- Add Choice x N
- Show Selection Window
- Assign Variable (this event content) (process selection result into another variable)
Related Event Contents
| Related event content | Purpose |
|---|---|
| Conditional Branch | Use the variable assigned by this event content in condition check |
| Move to Event | Evaluate variable condition in Determine and transition |
| Loop + Break Loop | Loop control via counter variable |
| Show Text Input | Save user input result as a string to a variable |
| Show Number Input | Save user input number to a variable |
Related Pages
| Page | Related content |
|---|---|
| Formula reference | Formula notation used in the Value property |
| Variable tab | Variable definition (prerequisite for this event content) |
| Text special notation | {variable name} expansion within text |
| Event Content List | List of all event contents |
Notes
Define variables in advance in the Variable tab
Only variables defined in advance in the Variable tab can be assigned to by this event content. Define the variable ID and initial value before use.
Wrong Assign calculation result mode leads to unintended results
- When Assign calculation result should be ON but is OFF, the formula is assigned as a string (
{counter} + 1is not calculated, and the string itself is stored) - When Assign calculation result should be OFF but is ON, the string is evaluated as a formula and errors occur (trying to interpret
Helloas an expression fails)
Select the correct mode according to your purpose.
Nonexistent variables are skipped (not an error)
If the specified variable does not exist in variable data, a warning log (*** WARNING : Variable is missing. : <variable name>) is output and processing silently proceeds to the next event content. The game does not stop, but intended processing does not execute, so check the log during debugging.
Deleted variables show an Error icon
When referencing a variable deleted in the Variable tab, it is displayed with an Error icon in the editor dropdown. Replace it with a correct variable ID if possible, or delete this event content itself.
Variable type switches on each assignment
Assigning with Assign calculation result ON makes it a number (float), and assigning with OFF makes it a string. Assigning to the same variable with different modes switches the type, so watch for integrity in other processing that references that variable.
Variable expansion is available in formulas
When Assign calculation result is ON, writing {other variable name} within Value expands to that variable's value and then calculates. This enables addition/subtraction between variables and parameter interlocking.
Variable expansion is not performed on string assignment
When Assign calculation result is OFF, {variable name} within Value is not expanded and is assigned as-is as a string. To expand after assigning the string when displaying text elsewhere, use {variable name} in Show Text.
