Skip to main content


MahiruAbout 2 min



Don't use the variable system until you figure out how to use scene jumping and branch jumping, it will be confusing!

Using Variables

To set a variable:

setVar:a=1; // You can set a number
setVar:a=true // You can set a boolean
setVar:a=Character Name // You can set a string

To set a random number, use random()


The random number is between 0 and 1, if you want to specify a range, you need to do some math. For example, if you want a random number between 5 and 10, you need to do:


You can also use previously defined variables when setting variables.


Conditional Execution

You can add a -when=(condition) parameter after a statement to conditionally execute the current statement.

For example:

; // Jump to scene 1 when a is greater than 1
changeScene:1.txt -when=a>1;
; // Jump only when a is 1, note that the equality operator is ==
changeScene:2.txt -when=a==1;
; // If a is less than 1, the above statements won't execute, so this one will


= is the assignment operator, it cannot be used in conditional statements, == is the equality operator.

Any statement can be conditionally executed with the -when parameter. By combining the -when parameter with jumpLabel callScene changeScene, you can achieve conditional flow control.

Getting User Input

Use the getUserInput statement to get user input, for example:

getUserInput:name -title=What's your name? -buttonText=OK; Store the user input in the variable name

Where title is the prompt text, buttonText is the text on the OK button

Variable Interpolation

You can use the {} syntax in statements to interpolate variables, passing a variable into the statement, for example:

{name}:Welcome to {engine}! This is a brand new visual novel engine for web.;

Persistent Variables (Global Variables)

Normal variables in WebGAL are存档 dependent, that is, any variable only exists in the current game scene, and only存档 can save it and read it back.

In order to solve the problem that the author may want to set multiple weeks, a persistent (global) variable is provided. Once set, it will take effect in the entire game, unless the user clears all data.

Adding the -global parameter can set persistent (global) variables

setVar:a=1 -global;

This sets a variable that does not change with存档 reading.

Example of use:

jumpLabel:turn-2 -when=a>0;
setVar:a=1 -global;
First playthrough;
changeScene:First playthrough plot.txt;
Second playthrough;
changeScene:Second playthrough plot.txt;