# Class: Label<T> (/jsdoc/pixi-vn/index/classes/Label)



Defined in: [src/narration/classes/Label.ts:33](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/Label.ts#L33)

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 [#example]

```typescript
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 [#extends]

* [`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract)\<`Label`\<`T`>, `T`>

Type Parameters [#type-parameters]

T [#t]

`T` *extends* `object` = \{ }

Constructors [#constructors]

Constructor [#constructor]

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

Defined in: [src/narration/classes/Label.ts:45](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/Label.ts#L45)

Parameters [#parameters]

id [#id]

`string`

is the id of the label

steps [#steps]

[`StepLabelType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelType)\<`T`>\[] | (() => [`StepLabelType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelType)\<`T`>\[])

is the list of steps that the label will perform

props? [#props]

[`LabelProps`](/jsdoc/pixi-vn/index/interfaces/LabelProps)\<`Label`\<`T`>, `number`>

is the properties of the label

Returns [#returns]

`Label`\<`T`>

Overrides [#overrides]

[`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract).[`constructor`](/jsdoc/pixi-vn/index/classes/LabelAbstract#constructor)

Properties [#properties]

id [#id-1]

\> `readonly` **id**: `string`

Defined in: [src/narration/classes/LabelAbstract.ts:23](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/LabelAbstract.ts#L23)

Get the id of the label. This variable is used in the system to get the label by id, [RegisteredLabels.get](/jsdoc/pixi-vn/index/namespaces/RegisteredLabels/functions/get)

Inherited from [#inherited-from]

[`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract).[`id`](/jsdoc/pixi-vn/index/classes/LabelAbstract#id)

Accessors [#accessors]

onLoadingLabel [#onloadinglabel]

Get Signature [#get-signature]

\> **get** **onLoadingLabel**(): ((`stepId`, `label`) => `void` | `Promise`\<`void`>) | `undefined`

Defined in: [src/narration/classes/LabelAbstract.ts:61](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/LabelAbstract.ts#L61)

Is a function that will be executed in [onStepStart](/jsdoc/pixi-vn/index/interfaces/LabelProps#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](/jsdoc/pixi-vn/index/interfaces/NarrationManagerInterface#openedlabels).
It is useful for example to make sure all images used have been cached

Example [#example-1]

```ts
newLabel("id", [], {
    onLoadingLabel: async (stepId, label) => {
        await Assets.load('path/to/image1.png')
        await Assets.load('path/to/image2.png')
    }
})
```

Returns [#returns-1]

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

Is a function that will be executed in [onStepStart](/jsdoc/pixi-vn/index/interfaces/LabelProps#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](/jsdoc/pixi-vn/index/interfaces/NarrationManagerInterface#openedlabels).
It is useful for example to make sure all images used have been cached

Example [#example-2]

```ts
newLabel("id", [], {
    onLoadingLabel: async (stepId, label) => {
        await Assets.load('path/to/image1.png')
        await Assets.load('path/to/image2.png')
    }
})
```

Inherited from [#inherited-from-1]

[`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract).[`onLoadingLabel`](/jsdoc/pixi-vn/index/classes/LabelAbstract#onloadinglabel)

***

onStepEnd [#onstepend]

Get Signature [#get-signature-1]

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

Defined in: [src/narration/classes/LabelAbstract.ts:68](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/LabelAbstract.ts#L68)

A function executed after each `step`. See more \<DynamicLink href="/start/labels-advanced#onstepend">here</DynamicLink>.

Example [#example-3]

```ts
const startLabel = newLabel("start", [
    async () => {
        await showImage("image1", "path/to/image1.png")
        await showImage("image2", "path/to/image2.png")
    }
], {
    onLoadingLabel: async (stepIndex, label) => {
        await Assets.load("path/to/image1.png")
        await Assets.load("path/to/image2.png")
    }
})
```

Returns [#returns-2]

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

A function executed after each `step`. See more \<DynamicLink href="/start/labels-advanced#onstepend">here</DynamicLink>.

Example [#example-4]

```ts
const startLabel = newLabel("start", [
    async () => {
        await showImage("image1", "path/to/image1.png")
        await showImage("image2", "path/to/image2.png")
    }
], {
    onLoadingLabel: async (stepIndex, label) => {
        await Assets.load("path/to/image1.png")
        await Assets.load("path/to/image2.png")
    }
})
```

Inherited from [#inherited-from-2]

[`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract).[`onStepEnd`](/jsdoc/pixi-vn/index/classes/LabelAbstract#onstepend)

***

onStepStart [#onstepstart]

Get Signature [#get-signature-2]

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

Defined in: [src/narration/classes/LabelAbstract.ts:45](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/LabelAbstract.ts#L45)

A function executed before each `step`.

Example [#example-5]

```ts
const startLabel = newLabel("start", [
    () => {
        narration.dialogue = "Step 1"
    },
    () => {
        narration.dialogue = "Step 2"
    }
], {
    onStepStart: (stepIndex, label) => {
        console.log(`Step ${stepIndex} started`)
    }
})
```

Returns [#returns-3]

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

A function executed before each `step`.

Example [#example-6]

```ts
const startLabel = newLabel("start", [
    () => {
        narration.dialogue = "Step 1"
    },
    () => {
        narration.dialogue = "Step 2"
    }
], {
    onStepStart: (stepIndex, label) => {
        console.log(`Step ${stepIndex} started`)
    }
})
```

Inherited from [#inherited-from-3]

[`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract).[`onStepStart`](/jsdoc/pixi-vn/index/classes/LabelAbstract#onstepstart)

***

stepCount [#stepcount]

Get Signature [#get-signature-3]

\> **get** **stepCount**(): `number`

Defined in: [src/narration/classes/Label.ts:34](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/Label.ts#L34)

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 [#returns-4]

`number`

The number of steps in the label

Overrides [#overrides-1]

[`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract).[`stepCount`](/jsdoc/pixi-vn/index/classes/LabelAbstract#stepcount)

***

steps [#steps-1]

Get Signature [#get-signature-4]

\> **get** **steps**(): [`StepLabelType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelType)\<`T`>\[]

Defined in: [src/narration/classes/Label.ts:58](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/Label.ts#L58)

Get the steps of the label.

Returns [#returns-5]

[`StepLabelType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelType)\<`T`>\[]

Methods [#methods]

getStepById() [#getstepbyid]

\> **getStepById**(`stepId`): [`StepLabelType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelType)\<`T`> | `undefined`

Defined in: [src/narration/classes/Label.ts:37](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/Label.ts#L37)

Get the step by id

Parameters [#parameters-1]

stepId [#stepid]

`number`

Id of the step

Returns [#returns-6]

[`StepLabelType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelType)\<`T`> | `undefined`

The step or undefined if it does not exist

Overrides [#overrides-2]

[`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract).[`getStepById`](/jsdoc/pixi-vn/index/classes/LabelAbstract#getstepbyid)

***

getStepSha() [#getstepsha]

\> **getStepSha**(`index`): `string`

Defined in: [src/narration/classes/Label.ts:65](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/classes/Label.ts#L65)

Get the sha of the step

Parameters [#parameters-2]

index [#index]

`number`

Index of the step

Returns [#returns-7]

`string`

Overrides [#overrides-3]

[`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract).[`getStepSha`](/jsdoc/pixi-vn/index/classes/LabelAbstract#getstepsha)
