Labels and steps
Explains the core concepts of labels and steps in Pixi’VN, detailing how narrative flow is structured and managed within the game engine.
Visual novels are typically a sequence of scenes with images and text. In Pixi’VN, the entire narrative flow is based on the concepts of labels and steps.
A label is used to organize the narrative; it works as a "bookmark" or section of the story. Technically, a label is a class that acts as a container for steps.
A step is an individual action or event that occurs within a label. Steps are used to display images, text, and other narrative elements.
Nomenclature
The term label is borrowed from Ren'Py, where it acts as a "bookmark" or "landmark" in the story. In the ink language, the equivalent term is knot.
The term step is introduced by Pixi’VN to represent the individual actions or events that occur within a label.
- The game starts by calling a
label, with theGame.startfunction. The firststepof thelabelis executed automatically. - After that, by connecting the
narration.continuefunction to an event (such as a button click), each time the function is called, the nextstepof thelabelis executed. Somestepscan also start otherlabels. - The game ends only when all
stepsare completed. At that point, theGame.onEndfunction is triggered.
Add
To create a label, use the newLabel function.
import { narration, StepLabelProps } from "@drincs/pixi-vn";
export const startLabel = newLabel("start", [
() => {
narration.dialogue = { character: liam, text: "Example of dialogue" };
},
(props: StepLabelProps, { labelId }) => narration.jump(labelId, props),
]);Other features
Templates
In all templates, the StepLabelProps interface is already overridden. You can find it in the pixi-vn.d.ts file.
All narration flow control functions require an object matching the StepLabelProps interface. You can "override" the StepLabelProps interface in your .d.ts file to specify required parameters.
import { narration } from "@drincs/pixi-vn";
declare module "@drincs/pixi-vn" {
interface StepLabelProps {
navigate: (route: string) => void;
}
}You can pass a type to the newLabel function to add custom parameters for that label, in addition to StepLabelProps.
import { narration } from "@drincs/pixi-vn";
export const startLabel = newLabel<{ name: string }>("start", [
(props) => {
console.log(props.name);
},
]);
narration.call(startLabel, {
// Add StepLabelProps here
navigate: navigate, // example
// And the custom props for the label
name: "John",
});Steps can return a StepLabelResult object. You can "override" the StepLabelResult interface in your .d.ts file to define custom properties for step results.
declare module "@drincs/pixi-vn" {
interface StepLabelResult {
newRoute?: string;
[key: string]: any;
}
}