Skip to content

ink variables

As explained in the official documentation of the ink language:

ink also supports variables, both temporary and global, storing numerical and content data, or even story flow commands. It is fully-featured in terms of logic, and contains a few additional structures to help keep the often complex logic of a branching story better organised.

In the ink + Pixi’VN integration, the variables VAR and CONST are equivalent to variables in storage. And the variables temp are equivalent to temporary variables in storage.

Just like in native ink you can use variables in dialogs or scripts that start with #.

The name of the variables of ink they are corresponding to the key of the variables in the storage. So For example, if you have the following ink code:

ink
VAR myVariable = 42

You can access the variable myVariable in the storage with the following code:

typescript
import { storage } from '@drincs/pixi-vn'

const myVariable = storage.getVariable<number>("myVariable");

Or vice versa, if you have the following code:

typescript
import { storage } from '@drincs/pixi-vn'

storage.setVariable("myDuration", 42);

You can access the variable myDuration in the ink code with the following code:

ink
// this is used to avoid the ink error, because the variable is not defined
VAR myDuration = 0

=== start ===
The value of myDuration is: {myDuration}
# show image bg /image.png dissolve duration {myDuration}
-> DONE