-
-
Notifications
You must be signed in to change notification settings - Fork 1
history
Pixi’VN save all dialogues, choices and responses that have been displayed in the game and all label and step opened.
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")
To get the already been made choices of the current step, you can use the narration.alreadyCurrentStepMadeChoices
.
const choices = narration.alreadyCurrentStepMadeChoices
To check if the current step is already been opened, you can use the narration.isCurrentStepAlreadyOpened
.
const isCurrentStepOpened = narration.isCurrentStepAlreadyOpened;
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;
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;
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);
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} :::