# Abstract Class: LabelAbstract<TLabel, TProps, StepIdType> (/jsdoc/pixi-vn/index/classes/LabelAbstract)



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

## Extended by [#extended-by]

* [`Label`](/jsdoc/pixi-vn/index/classes/Label)

## Type Parameters [#type-parameters]

### TLabel [#tlabel]

`TLabel`

### TProps [#tprops]

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

### StepIdType [#stepidtype]

`StepIdType` = `number`

## Implements [#implements]

* [`LabelProps`](/jsdoc/pixi-vn/index/interfaces/LabelProps)\<`TLabel`, `StepIdType`>

## Constructors [#constructors]

### Constructor [#constructor]

\> **new LabelAbstract**\<`TLabel`, `TProps`, `StepIdType`>(`id`, `props?`): `LabelAbstract`\<`TLabel`, `TProps`, `StepIdType`>

Defined in: [src/narration/classes/LabelAbstract.ts:12](https://github.com/DRincs-Productions/pixi-vn/blob/92a10d7481511296d22e17c43fbc1d4dd976bef8/src/narration/classes/LabelAbstract.ts#L12)

#### Parameters [#parameters]

##### id [#id]

`string`

is the id of the label

##### props? [#props]

[`LabelProps`](/jsdoc/pixi-vn/index/interfaces/LabelProps)\<`TLabel`, `StepIdType`>

is the properties of the label

#### Returns [#returns]

`LabelAbstract`\<`TLabel`, `TProps`, `StepIdType`>

## Properties [#properties]

### id [#id-1]

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

Defined in: [src/narration/classes/LabelAbstract.ts:22](https://github.com/DRincs-Productions/pixi-vn/blob/92a10d7481511296d22e17c43fbc1d4dd976bef8/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](/jsdoc/pixi-vn/index/namespaces/RegisteredLabels/functions/get)

## 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/92a10d7481511296d22e17c43fbc1d4dd976bef8/src/narration/classes/LabelAbstract.ts#L60)

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]

```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](/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 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')
    }
})
```

#### Implementation of [#implementation-of]

[`LabelProps`](/jsdoc/pixi-vn/index/interfaces/LabelProps).[`onLoadingLabel`](/jsdoc/pixi-vn/index/interfaces/LabelProps#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/92a10d7481511296d22e17c43fbc1d4dd976bef8/src/narration/classes/LabelAbstract.ts#L67)

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

##### Example [#example-2]

```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-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")
    }
})
```

#### Implementation of [#implementation-of-1]

[`LabelProps`](/jsdoc/pixi-vn/index/interfaces/LabelProps).[`onStepEnd`](/jsdoc/pixi-vn/index/interfaces/LabelProps#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/92a10d7481511296d22e17c43fbc1d4dd976bef8/src/narration/classes/LabelAbstract.ts#L44)

A function executed before each `step`.

##### Example [#example-4]

```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-5]

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

#### Implementation of [#implementation-of-2]

[`LabelProps`](/jsdoc/pixi-vn/index/interfaces/LabelProps).[`onStepStart`](/jsdoc/pixi-vn/index/interfaces/LabelProps#onstepstart)

***

### stepCount [#stepcount]

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

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

Defined in: [src/narration/classes/LabelAbstract.ts:28](https://github.com/DRincs-Productions/pixi-vn/blob/92a10d7481511296d22e17c43fbc1d4dd976bef8/src/narration/classes/LabelAbstract.ts#L28)

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

## Methods [#methods]

### getStepById() [#getstepbyid]

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

Defined in: [src/narration/classes/LabelAbstract.ts:41](https://github.com/DRincs-Productions/pixi-vn/blob/92a10d7481511296d22e17c43fbc1d4dd976bef8/src/narration/classes/LabelAbstract.ts#L41)

Get the step by id

#### Parameters [#parameters-1]

##### stepId [#stepid]

`StepIdType`

Id of the step

#### Returns [#returns-5]

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

The step or undefined if it does not exist

***

### getStepSha() [#getstepsha]

\> `abstract` **getStepSha**(`stepId`): `string` | `undefined`

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

Get the sha of the step

#### Parameters [#parameters-2]

##### stepId [#stepid-1]

`StepIdType`

#### Returns [#returns-6]

`string` | `undefined`
