Pixi’VN
indexNamespacesGameFunctions

Function: addOnRestoreGameState()

pixi-vn on GitHub

> addOnRestoreGameState(handler, options?): () => void

Defined in: src/index.ts:330

Register a handler that runs every time restoreGameState is called. It receives the exact save-state object passed to restoreGameState, so an external library can read back the data it added through addOnExportGameState. Handlers may be async; handlers with the same timing are awaited sequentially in registration order, and an error thrown by a handler is propagated to the restoreGameState caller.

Parameters

handler

OnRestoreGameStateHandler

The handler to register.

options?

OnRestoreGameStateOptions = {}

timing: "before" (default) runs the handler before any built-in module is restored; "after" runs it once the built-in restoration and navigation have completed.

Returns

A function that removes the handler (same as removeOnRestoreGameState).

() => void

Example

Game.addOnRestoreGameState((state) => {
    myLibrary.load(state.myLibraryData);
});
Game.addOnRestoreGameState(
    (state) => {
        myLibrary.refreshUi();
    },
    { timing: "after" },
);

On this page