# 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:

ActionCodeDescriptionExample
AddaddAdds a value to the variablegold + 50 = 150
SubtractminusSubtracts a value from the variablehealth_points - 20 = 80
AssignsetReplaces the current valuefaction = "Rebels"
Assign oncesetOnceAssigns only if the variable has never been modifiedfirst_choice = "diplomacy"
setOnce is valuable

Use setOnce to remember the reader's first action without it being overwritten later. Perfect for determining a gameplay "tendency" or a first moral choice.

# 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 typeCodeDescription
Time periodTimeOfDayPeriodThe choice is only available at certain hours
Character unlockCharacterUnlockThe choice requires having unlocked a character detail
Delay afterDelayAfterThe choice appears after a delay in minutes
Delay beforeDelayBeforeThe choice disappears after a certain time
Element unlockElementUnlockThe choice requires possessing an element
Step readStepReadThe choice requires having read a specific step
Event readEventReadThe choice requires having received an event
Current playerCurrentPlayerThe choice is reserved for a specific player
Multiple conditions configuration
Combine multiple conditions to create sophisticated branching.
Beware of overly restrictive combinations

The more conditions you add, the harder it becomes for the reader to meet all requirements. Make sure there is always at least one accessible path.

# Comparison operators

For variable-based conditions, you have several comparison operators available:

OperatorCodeDescriptionExample
Equal toeqThe variable must be exactly equal to the valuefaction eq "Rebels"
Less thanltThe variable must be strictly lesshealth_points lt 20
Greater thangtThe variable must be strictly greatergold gt 100
Less than or equalletThe variable must be less than or equalenergy let 50
Greater than or equalgetThe variable must be greater than or equalreputation 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

Use a shared variable "chest_key": player 1 finds the key (set to true), which automatically unlocks the chest for player 2 at a different step.

# 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:

VariableDescriptionRendered example
FirstNameReader's first nameMarie
LastNameReader's last nameDupont
FullNameFull first and last nameMarie Dupont
AgeReader's age28
CurrentTimeReader's current time14:35
PlayerFirstName:XFirst name of player X (multiplayer)Lucas
Maximum immersion

Combine system variables with your custom variables for total immersion: "{{FirstName}}, it is {{CurrentTime}}. You have {{unread_messages}} messages waiting."

# 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
Variable debugging
Test different value combinations to validate your scenarios.