Class: LabelJson<T>
Defined in: src/interpreter/LabelJson.ts:53
A label whose steps are defined by a plain JSON structure (PixiVNJsonLabelStep[]).
LabelJson bridges pixi-vn's label system and the JSON script format: each step is
lazily converted to a StepLabelType closure that resolves dialogues, choices,
operations, and conditional overrides at runtime via JsonUnifier.
Extends
LabelAbstract<LabelJson<T>,T>
Type Parameters
T
T extends object = object
The type of the props object passed between steps.
Constructors
Constructor
> new LabelJson<T>(id, steps, props?, options?): LabelJson<T>
Defined in: src/interpreter/LabelJson.ts:59
Parameters
id
string
is the id of the label
steps
(PixiVNJsonLabelStep | (() => PixiVNJsonLabelStep))[]
is the list of steps that the label will perform
props?
LabelProps<LabelJson<T>, number>
is the properties of the label
options?
LabelJsonOptions = {}
Returns
LabelJson<T>
Overrides
LabelAbstract<LabelJson<T>, T>.constructor
Properties
id
> readonly id: string
Defined in: node_modules/@drincs/pixi-vn/dist/narration.d.ts:52
Get the id of the label. This variable is used in the system to get the label by id, RegisteredLabels.get
Inherited from
LabelAbstract.id
Accessors
onLoadingLabel
Get Signature
> get onLoadingLabel(): ((stepId, label) => void | Promise<void>) | undefined
Defined in: node_modules/@drincs/pixi-vn/dist/narration.d.ts:72
Is a function that will be executed in Label.onStepStart if the id of the step is 0 and when the user laods a save file. When you load a save file, will be executed all onLoadingLabel functions of the narration.openedLabels. It is useful for example to make sure all images used have been cached
Example
newLabel("id", [], {
onLoadingLabel: async (stepId, label) => {
await Assets.load('path/to/image1.png')
await Assets.load('path/to/image2.png')
}
})
Returns
((stepId, label) => void | Promise<void>) | undefined
Inherited from
LabelAbstract.onLoadingLabel
onStepEnd
Get Signature
> get onStepEnd(): ((stepId, label) => void | Promise<void>) | undefined
Defined in: node_modules/@drincs/pixi-vn/dist/narration.d.ts:74
Is a function that will be executed when the step ends.
Returns
((stepId, label) => void | Promise<void>) | undefined
Inherited from
LabelAbstract.onStepEnd
onStepStart
Get Signature
> get onStepStart(): ((stepId, label) => void | Promise<void>) | undefined
Defined in: node_modules/@drincs/pixi-vn/dist/narration.d.ts:70
Is a function that will be executed before any step is executed.
Returns
((stepId, label) => void | Promise<void>) | undefined
Inherited from
LabelAbstract.onStepStart
stepCount
Get Signature
> get stepCount(): number
Defined in: src/interpreter/LabelJson.ts:106
Get the number of steps in the label. This variable is used in the system to get the number of steps in the label.
Returns
number
The number of steps in the label
Overrides
LabelAbstract.stepCount
steps
Get Signature
> get steps(): StepLabelType<T>[]
Defined in: src/interpreter/LabelJson.ts:101
Returns
StepLabelType<T>[]
Methods
getStepById()
> getStepById(stepId): StepLabelType<T> | undefined
Defined in: src/interpreter/LabelJson.ts:109
Get the step by id
Parameters
stepId
number
Id of the step
Returns
StepLabelType<T> | undefined
The step or undefined if it does not exist
Overrides
LabelAbstract.getStepById
getStepSha()
> getStepSha(index): string | undefined
Defined in: src/interpreter/LabelJson.ts:131
Returns the SHA-1 hash of the raw step at the given index. Can be used to detect step changes across label reloads.
Parameters
index
number
Zero-based index of the step.
Returns
string | undefined
The hex SHA-1 string, or undefined if the index is out of range.
Overrides
LabelAbstract.getStepSha