Studio

FolioTier 1

set

Assign a project variable from a bounded expression.

set is how you track state that changes as the story progresses. Use it to record a player choice, count how many times something has happened, or flag that a scene has been visited. Any piece of information you need to carry from one moment in the script to another lives in a variable you manage with set.

A variable springs into existence the first time you set it. Folio infers whether it holds a number, a string, or a boolean from that initial assignment and enforces that type for the rest of the project. Name variables for what they mean to the story, not for how they are used mechanically - a name like love or has-key makes a script far easier to read at a glance than x or flag1.

Because the value expression follows the same grammar as an if condition, the same constraints apply: you can do arithmetic, reference other variables, and test membership, but you cannot call anything that would change state mid-expression. Expressions are evaluated once and the result is stored - nothing happens as a side effect of computing the value.

If you assign a variable before the player has had a chance to influence it, that first set establishes the default. Placing these initializations near the top of your starting scene makes it easy to audit what state the project begins with.

Type is locked after first assignment. Trying to store a number into a variable that was first set to a boolean will raise an error at build time, not at runtime - so you will catch the mismatch before a player ever sees it.

Parameters

ParameterKindRequiredDefaultNotes
variableidentifieryes-Identifier of the variable being assigned. Variables are declared by first use; the type is inferred from the first assignment and can be number, string, or boolean.
valueexpressionyes-Expression evaluated and assigned to the variable. Same bounded grammar as `if` conditions - literals, arithmetic, references to other variables, membership tests. No side-effecting calls; expressions are pure.

Canonical example

Folio
set has-key = true
set love = 0
set love = love + 1
Ren'Py
$ has_key = True
$ love = 0
$ love += 1

set is the variable assignment verb. Variables live for the duration of the playthrough and are persisted with the save state. There's no explicit declaration step - the first set to a variable name creates it; the inferred type comes from the first value.

Notes

The right-hand side accepts arithmetic and references to other variables. set love = love + 1 is the canonical counter pattern (Ren'Py's $ love += 1), and set pov = hero copies one variable into another. A bare identifier on the right reads a variable - quote it (set name = "Aria") for a literal string. A number or true/false is taken literally. Imported $-assignments of these shapes are recovered automatically; a string concatenation (a + " " + b) is not, and stays flagged for manual review.

set is not a way to call into Python or invoke arbitrary methods. The right-hand side is a pure expression - no renpy.* calls, no method invocations on custom objects, no I/O. If the source Ren'Py uses $ <expr> to do those, the importer routes the fragment to the AI pass or the manual lane.

See also

  • when - read the variables set writes to gate a block
  • variables - declaration, scope, persistence