Skip to content

history

Black Ram edited this page Nov 14, 2024 · 18 revisions

History

Pixi’VN save all dialogues, choices and responses that have been displayed in the game and all label and step opened.

Check if the label has already been completed

To check if a label has already been completed, you can use the narration.isLabelAlreadyCompleted function.

The function takes the following parameters:

  • label: The label to check if it is already completed.
const isLabelCompleted = narration.isLabelAlreadyCompleted(startLabel)
const isLabelCompleted = narration.isLabelAlreadyCompleted("labelid")

Get already been made choices of current step

To get the already been made choices of the current step, you can use the narration.alreadyCurrentStepMadeChoices.

const choices = narration.alreadyCurrentStepMadeChoices

Check if current step is already been opened

To check if the current step is already been opened, you can use the narration.isCurrentStepAlreadyOpened.

const isCurrentStepOpened = narration.isCurrentStepAlreadyOpened;

Counter of execution times of the current step

To get the counter of execution times of the current step, you can use the narration.currentStepTimesCounter. Important: The counter will be incremented only if narration.currentStepTimesCounter is called at least once in a step.

export const label = newLabel("id",
    () => {
        if (narration.currentStepTimesCounter === 0) { // ✅ will be incremented
            // ...
        } else {
            // ...
        }
    }
)
export const label = newLabel("id",
    () => {
        if (narration.currentStepTimesCounter === 0) { // ✅ will be incremented
            // ...
        } else if (narration.currentStepTimesCounter === 1) { // ✅ It will not be incremented, because it has already been incremented in this step
            // ...
        }
    }
)
export const label = newLabel("id",
    () => {
        if (flag) {
            if (narration.currentStepTimesCounter === 1) { // ❌ It will be incremented only if "flag" is true
                // ...
            }
        }
    }
)

To restart the counter of execution times of the current step, you can use the narration.currentStepTimesCounter = 0.

narration.currentStepTimesCounter = 0;

Get Narrative History

The Narration timeline of the game is a list of all dialogues that have been displayed. It is useful to show the history of dialogues and choices to the player.

To get the narrative history of the game, you can use the narration.narrativeHistory. It returns a list of NarrativeHistory<T>[].

const dialogues: NarrativeHistory<Dialogue>[] = narration.narrativeHistory;

Delete Narrative History

To delete all the narrative history, use the narration.removeNarrativeHistory.

narration.removeNarrativeHistory();

To delete a part of the narrative history, use the narration.removeNarrativeHistory.

// delete the first 2 elements
narration.removeNarrativeHistory(2);

How to create the history UI screen

For example:

( It's in basic html, you will need to replace the basic html elements with UI components from your favorite library to improve the graphics. )

::: sandbox {template=ryzljv entry=/src/screens/HistoryScreen.tsx} :::

Clone this wiki locally