Skip to content

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:

ModeBehaviorPurpose
Assign calculation result ONEvaluates Value as a formula, assigns the result (number)Counter update, flag (1/0), saving calculation result
Assign calculation result OFFAssigns the Value string as-isFixed text, holding player input results

Property List ​

Item (tscn label)Input typeDescription
VariableSelectionDestination variable (selected from those defined in the Variable tab)
ValueFormula or stringValue to assign (interpretation changes based on Assign calculation result ON/OFF)
Assign calculation resultCheckboxON = 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 number 0 to the variable (flag reset)
  • 1 -> assigns the number 1 to the variable (flag set)
  • {counter} + 1 -> increments the counter by 1
  • {counter} * 2 -> doubles the counter
  • MEM_0.LEVEL.NOW -> assigns the level of the leading member
  • PARTY.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 variable
  • yes -> 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) ​

  1. Formula.replace_all() expands variable expansions and references within Value
  2. Formula.calc() evaluates the formula
  3. 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:

  1. Assign Variable (this event content)
    • Variable: counter
    • Value: {counter} + 1
    • Assign calculation result: ON

Flow 2: Flag set / reset ​

Set a flag (assign 1):

  1. Assign Variable (this event content)
    • Variable: flag_quest_started
    • Value: 1
    • Assign calculation result: ON

Reset a flag (assign 0):

  1. Assign Variable (this event content)
    • Variable: flag_quest_started
    • Value: 0
    • Assign calculation result: ON

Flow 3: Save party gold to a variable ​

Record a value you want to reference later:

  1. Assign Variable (this event content)
    • Variable: gold_snapshot
    • Value: PARTY.GOLD
    • Assign calculation result: ON
  2. (An event where gold may change due to some processing)
  3. Conditional Branch (Formula PARTY.GOLD < {gold_snapshot})
  4. Show Text <- "The gold has decreased!"
  5. End If

Flow 4: String assignment (fixed text) ​

Assign an NPC name to a variable:

  1. Assign Variable (this event content)
    • Variable: last_npc_name
    • Value: Alice
    • Assign calculation result: OFF
  2. Show Text <- "I met {last_npc_name}"

Flow 5: Value switching based on condition ​

Assign different values based on HP remaining:

  1. Conditional Branch (Formula MEM_0.HP.RATE >= 0.5)
  2. Assign Variable (this event content) (variable status, value good, calculation result OFF)
  3. Else
  4. Assign Variable (this event content) (variable status, value bad, calculation result OFF)
  5. End If

Flow 6: Loop with counter ​

Counter management for looping:

  1. Assign Variable (this event content) (variable i, value 0, calculation result ON) <- initialization
  2. Loop
  3. Conditional Branch (Formula {i} >= 5)
  4. Break Loop
  5. End If
  6. Show Text <- loop processing
  7. Assign Variable (this event content) (variable i, value {i} + 1, calculation result ON) <- increment
  8. Loop End

Flow 7: Complex calculation result assignment ​

Assign a value calculated from multiple parameters:

  1. 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

Flow 8: Game statistics recording ​

Count the number of plays:

  1. 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:

  1. Assign Variable (this event content) (initialization, i = 0)
  2. Loop
  3. Conditional Branch ({i} >= N) + Break Loop
  4. (Loop processing)
  5. Assign Variable (this event content) (increment, {i} + 1)
  6. Loop End

Flag management ​

Flag set -> reference in branch:

  1. Assign Variable (this event content) (flag_X = 1)
  2. ... another event ...
  3. Conditional Branch ({flag_X} == 1)
  4. (Processing)
  5. End If

Snapshot + comparison ​

State save -> change check:

  1. Assign Variable (this event content) (snapshot save)
  2. (State change event)
  3. Conditional Branch (change check)

Processing selection results ​

Reflect selection in a variable:

  1. Add Choice x N
  2. Show Selection Window
  3. Assign Variable (this event content) (process selection result into another variable)
Related event contentPurpose
Conditional BranchUse the variable assigned by this event content in condition check
Move to EventEvaluate variable condition in Determine and transition
Loop + Break LoopLoop control via counter variable
Show Text InputSave user input result as a string to a variable
Show Number InputSave user input number to a variable
PageRelated content
Formula referenceFormula notation used in the Value property
Variable tabVariable definition (prerequisite for this event content)
Text special notation{variable name} expansion within text
Event Content ListList 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} + 1 is 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 Hello as 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.