LogoPixi’VN
indexClasses

Class: Label<T>

Defined in: src/narration/classes/Label.ts:33

Label is a class that contains a list of steps, which will be performed as the game continues. For Ren'py this is the equivalent of a label.

Example

const START_LABEL_ID = "StartLabel"

export const startLabel = newLabel(START_LABEL_ID,
    [
        (props) => {
            canvas.clear()
            narration.dialogue = { character: liam, text: "Which test do you want to perform?" }
            narration.choices = [
                newChoiceOption("Events Test", eventsTestLabel),
                newChoiceOption("Show Image Test", showImageTest),
            ]
        },
        (props) => narration.jump(START_LABEL_ID, props),
    ]
)

narration.call(StartLabel)

Extends

Type Parameters

T

T extends object = { }

Constructors

Constructor

> new Label<T>(id, steps, props?): Label<T>

Defined in: src/narration/classes/Label.ts:45

Parameters

id

string

is the id of the label

steps

StepLabelType<T>[] | (() => StepLabelType<T>[])

is the list of steps that the label will perform

props?

LabelProps<Label<T>, number>

is the properties of the label

Returns

Label<T>

Overrides

LabelAbstract.constructor

Properties

id

> readonly id: string

Defined in: src/narration/classes/LabelAbstract.ts:23

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: src/narration/classes/LabelAbstract.ts:61

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

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')
    }
})

Inherited from

LabelAbstract.onLoadingLabel


onStepEnd

Get Signature

> get onStepEnd(): ((stepId, label) => void | Promise<void>) | undefined

Defined in: src/narration/classes/LabelAbstract.ts:68

Is a function that will be executed when the step ends.

Returns

((stepId, label) => void | Promise<void>) | undefined

Is a function that will be executed when the step ends.

Inherited from

LabelAbstract.onStepEnd


onStepStart

Get Signature

> get onStepStart(): ((stepId, label) => void | Promise<void>) | undefined

Defined in: src/narration/classes/LabelAbstract.ts:45

Is a function that will be executed before any step is executed.

Returns

((stepId, label) => void | Promise<void>) | undefined

Is a function that will be executed before any step is executed.

Inherited from

LabelAbstract.onStepStart


stepCount

Get Signature

> get stepCount(): number

Defined in: src/narration/classes/Label.ts:34

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/narration/classes/Label.ts:58

Get the steps of the label.

Returns

StepLabelType<T>[]

Methods

getStepById()

> getStepById(stepId): StepLabelType<T> | undefined

Defined in: src/narration/classes/Label.ts:37

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

Defined in: src/narration/classes/Label.ts:65

Get the sha of the step

Parameters

index

number

Index of the step

Returns

string

Overrides

LabelAbstract.getStepSha