LogoPixi’VN

Storage

Cómo almacenar, recuperar y gestionar variables persistentes y temporales en Pixi'VN, incluyendo la integración con Keyv.

What is the game storage? The game storage is a place where you can save variables that you want to keep between game sessions.

It is essential to understand that if variables are not saved in the game memory, the engine will not be able to handle them when you load a save or when you go back.

Additionally, in the game archive you can save any type of variable, except class and function (because they cannot be converted to JSON), such as: string, number, boolean, object, array, etc. If you want to save "flags" (boolean), it is recommended to use the flags functionality, a very high-performance flag management system.

ink

You can use this method with the ink syntax. Más información aquí.

Establecer

Para establecer una variable en el almacenamiento del juego, utiliza storage.set. This function has the following parameters:

  • name: El nombre de la variable a establecer.
  • value: El valor de la variable a establecer.
import { storage } from '@drincs/pixi-vn'

storage.set("myVariable", 42);

Obtener

To get a variable from the game storage, use storage.get. This function has the following parameters:

  • name: El nombre de la variable a obtener.
import { storage } from '@drincs/pixi-vn'

const myVariable = storage.get("myVariable");

Eliminar

To remove a variable from the game storage, use storage.remove. This function has the following parameters:

  • name: El nombre de la variable a eliminar.
import { storage } from '@drincs/pixi-vn'

storage.remove("myVariable");

Otras funcionalidades

On this page