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



Defined in: [src/narration/classes/Label.ts:33](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/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]

```ts
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`](/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/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/narration/classes/Label.ts#L45)

#### Parameters [#parameters]

##### id [#id]

`string`

is the id of the label

##### steps [#steps]

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

is the list of steps that the label will perform

##### props? [#props]

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

is the properties of the label

#### Returns [#returns]

`Label`\<`T`>

#### Overrides [#overrides]

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

## Properties [#properties]

### id [#id-1]

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

Defined in: [src/narration/classes/LabelAbstract.ts:22](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/narration/classes/LabelAbstract.ts#L22)

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

#### Inherited from [#inherited-from]

[`LabelAbstract`](/pixi-vn/index/classes/LabelAbstract).[`id`](/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:60](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/narration/classes/LabelAbstract.ts#L60)

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

##### Example [#example-1]

```ts title="content/labels/start.label.ts"
newLabel("start", [], {
    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](/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](/pixi-vn/index/interfaces/NarrationManagerInterface#openedlabels).
It is useful for example to make sure all images used have been cached

#### Example [#example-2]

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

#### Inherited from [#inherited-from-1]

[`LabelAbstract`](/pixi-vn/index/classes/LabelAbstract).[`onLoadingLabel`](/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:67](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/narration/classes/LabelAbstract.ts#L67)

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`](/pixi-vn/index/classes/LabelAbstract).[`onStepEnd`](/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:44](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/narration/classes/LabelAbstract.ts#L44)

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`](/pixi-vn/index/classes/LabelAbstract).[`onStepStart`](/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/5bb5bb1f92e38998ea2f477b600168d8da3ece19/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`](/pixi-vn/index/classes/LabelAbstract).[`stepCount`](/pixi-vn/index/classes/LabelAbstract#stepcount)

***

### steps [#steps-1]

#### Get Signature [#get-signature-4]

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

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

Get the steps of the label.

##### Returns [#returns-5]

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

## Methods [#methods]

### getStepById() [#getstepbyid]

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

Defined in: [src/narration/classes/Label.ts:37](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/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`](/pixi-vn/index/type-aliases/StepLabelType)\<`T`> | `undefined`

The step or undefined if it does not exist

#### Overrides [#overrides-2]

[`LabelAbstract`](/pixi-vn/index/classes/LabelAbstract).[`getStepById`](/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/5bb5bb1f92e38998ea2f477b600168d8da3ece19/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`](/pixi-vn/index/classes/LabelAbstract).[`getStepSha`](/pixi-vn/index/classes/LabelAbstract#getstepsha)
