# Advanced variables
Livre Arbitre's variable system goes far beyond simple counters. This guide delves into actions, complex conditions, comparison operators and advanced techniques to create truly dynamic narratives.
# Variable actions in detail
When the reader reaches a step, you can trigger actions that modify your variable values. Four types of actions are available:
| Action | Code | Description | Example |
|---|---|---|---|
| Add | add | Adds a value to the variable | gold + 50 = 150 |
| Subtract | minus | Subtracts a value from the variable | health_points - 20 = 80 |
| Assign | set | Replaces the current value | faction = "Rebels" |
| Assign once | setOnce | Assigns only if the variable has never been modified | first_choice = "diplomacy" |
setOnce is valuable
# Complex condition combinations
Conditions on links between steps are not limited to variables. You can combine multiple condition types to create sophisticated scenarios. The available conditions are:
| Condition type | Code | Description |
|---|---|---|
| Time period | TimeOfDayPeriod | The choice is only available at certain hours |
| Character unlock | CharacterUnlock | The choice requires having unlocked a character detail |
| Delay after | DelayAfter | The choice appears after a delay in minutes |
| Delay before | DelayBefore | The choice disappears after a certain time |
| Element unlock | ElementUnlock | The choice requires possessing an element |
| Step read | StepRead | The choice requires having read a specific step |
| Event read | EventRead | The choice requires having received an event |
| Current player | CurrentPlayer | The choice is reserved for a specific player |

Beware of overly restrictive combinations
# Comparison operators
For variable-based conditions, you have several comparison operators available:
| Operator | Code | Description | Example |
|---|---|---|---|
| Equal to | eq | The variable must be exactly equal to the value | faction eq "Rebels" |
| Less than | lt | The variable must be strictly less | health_points lt 20 |
| Greater than | gt | The variable must be strictly greater | gold gt 100 |
| Less than or equal | let | The variable must be less than or equal | energy let 50 |
| Greater than or equal | get | The variable must be greater than or equal | reputation get 75 |
# Shared and private variables in multiplayer
In multiplayer mode, variable scope becomes an essential strategic tool. Understanding the difference between shared and private variables is crucial for creating coherent multiplayer experiences.
- Private variables — Each player has their own instance of the variable. Ideal for individual inventory, health points, personal choices
- Shared variables — All players share the same value. Ideal for world state, open doors, common quests
- Strategic impact — A shared variable modified by one player immediately affects all other players
Cooperative scenario
# Inserting variables in content
Variables can be inserted directly into your step text using the {{variable_name}} syntax. At reading time, the double curly braces are replaced by the variable's current value.
- Text personalization — "Welcome, {{FirstName}}! You have {{gold}} gold coins."
- Dynamic narration — "You have been a member of the {{faction}} for {{days_member}} days."
- Personalized dialogues — "{{PlayerFirstName:2}} looks at you with suspicion."
# System variables
In addition to your custom variables, Livre Arbitre provides ready-to-use system variables:
| Variable | Description | Rendered example |
|---|---|---|
| FirstName | Reader's first name | Marie |
| LastName | Reader's last name | Dupont |
| FullName | Full first and last name | Marie Dupont |
| Age | Reader's age | 28 |
| CurrentTime | Reader's current time | 14:35 |
| PlayerFirstName:X | First name of player X (multiplayer) | Lucas |
Maximum immersion
# Debugging variables
Testing the different scenarios related to variables is essential to ensure a smooth reading experience. Here are the best practices for debugging your variables:
- Test every path — Go through all branches to verify that variables are correctly modified
- Check boundary values — Test cases where a variable reaches 0, its maximum or an unexpected value
- Verify conditions — Make sure your link conditions work with different variable combinations
- Use the preview — The editor preview lets you see variable rendering without launching a full reading session
- Document your variables — Use internal descriptions to note the role and value range of each variable
