Variables serve to store and manage dynamic information during the game's execution. They can be used for a wide range of purposes, including:
In essence, variables are crucial for making games dynamic, interactive, and adaptable, allowing players to actively influence the game world and game mechanics to respond accordingly.
In Homer, you can define variables and modify their value at each step of the flow.
You have two types of variables: global variables and local variables.
This kind of variable is strongly typed, and it can only store values of that type. Any attempt to assign a value of a different type will result in an error. They are stored in the project, and you can manage them by accessing the “Variable panel” from the main project menu.

Global variables are always preceded by the $ and must be named without spaces or any special characters.
For example:
✓ $myTextVariable or $my_text_variable
✗ $my Variable or $my+variable
If you are in a Text node ****or a Choice node, variables must be surrounded by curly braces if they are expressions:
{$myTextVariable = “Pippo”}
Otherwise (in a conditional node or a Variables node), you don’t need to surround them with curly braces.
$myTextVariable = “Pippo”
In a Text or a Choice node, ****if you ****nominate it without setting its value {$myTextVariable}, its value will be printed out once the flow is running. In this case, variables can be written without curly braces $myTextVariable.
Expression variables allow you to store the result of a calculation or logical expression and reuse it throughout your story. Unlike standard variables, their value is automatically computed from an expression rather than assigned directly.
Examples:
$TOTAL = $GOLD + $BONUS
$CAN_BUY = $GOLD >= $ITEM_COST
$DISCOUNT = $PRICE * 0.2
Expression variables are useful for derived values, conditions, counters, scores, and any data that depends on other variables. They help keep your narrative logic clean by centralizing calculations instead of repeating the same expressions across multiple nodes.
When you type the $ character, a pop-up displaying the available variables will appear to help with variable insertion.

You can add a new global variable either by introducing it in the context of the text of a node or from the Variable panel.

Once the variable has been created, you can set its default value from the Variable panel.
Changing the name of the variable from the Variable panel will refactor any use of that variable in all the flows of the project.
This kind of variable is generic, and its scope is confined to the running flow.
Local variables are always preceded by the % and must be named without spaces or any special characters.
For example:
✓ %myVariable or %my_variable
✗ %my Variable or %my+variable
If you are in a Text node ****or a Choice node, variables must be surrounded by curly braces:
{%myVariable = “My string”}
Otherwise (in a conditional node or a Variables node), you don’t need to surround them with curly braces.
%myVariable = “My string”
In a Text or a Choice node, ****nominating it without setting its value {%myVariable}, its value will be printed out once the flow is running. In this case, variables can be written without curly braces %myVariable.
Any valid operator can be used to set the variable value:
For Global Variables, the value must respect the type of the variable:
✓ $myTextVariable = “My string”
✓ $myTextVariable = “My string ” + $mySecondTextVariable
✗ $myTextVariable = 12
✓ $myIntVariable = 123
✓ $myIntVariable = 123 + $mySecondIntVariable
✓ $myIntVariable ++
✗ $myIntVariable = “Abc”
For Local Variables, the value can be of any type:
✓ %myVariable = “My string”
✓ %myVariable = “My string ” + $mySecondVariable
✓ %myVariable = 12
To increment the value of a variable:
✓ $myIntVariable = $myIntVariable + 1
✓ $myIntVariable ++
✗ $myIntVariable += 1 (would work only for JavaScript projects)
In Conditional nodes, the condition expressed must always return a Boolean:
✓ $myIntVariable == 10
✓ $myIntVariable >= 10
✓ $myBoolVariable
✗ $myIntVariable = 1
Homer will parse and verify your variables and will display an alert each time the variable definition is wrong.
