# Interface: NarrationManagerInterface (/jsdoc/pixi-vn/index/interfaces/NarrationManagerInterface)



Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:16](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L16)

Properties [#properties]

alreadyCurrentStepMadeChoices [#alreadycurrentstepmadechoices]

\> `readonly` **alreadyCurrentStepMadeChoices**: `number`\[] | `undefined`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:82](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L82)

Get the choices already made in the current step. **Attention**: if the choice step index is edited or the code of choice step is edited, the result will be wrong.

Returns [#returns]

The choices already made in the current step. If there are no choices, it will return undefined.

***

canContinue [#cancontinue]

\> `readonly` **canContinue**: `boolean`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:110](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L110)

Return if can go to the next step.

Returns [#returns-1]

True if can go to the next step.

***

continue [#continue]

\> **continue**: (`props`, `options?`) => `Promise`\<[`StepLabelResultType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelResultType)>

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:136](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L136)

Execute the next step and add it to the history. If a step is already running, it will put the request in the queue,
and when the step is finished, it will execute the next step.

Parameters [#parameters]

props [#props]

`StepLabelProps`

The props to pass to the step.

options? [#options]

The options.

runNow? [#runnow]

`boolean`

If true, ignore the running step, ignore the choice menu/required input and run the next step immediately.

steps? [#steps]

`number`

The number of steps to advance. Must be a valid finite number greater than 0.
If NaN, Infinity, or a value less than or equal to 0 is provided, the implementation
will emit a warning and return early without advancing steps.

**Default**

```ts
1
```

Returns [#returns-2]

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

StepLabelResultType or undefined.

Example [#example]

```typescript
    function nextOnClick() {
    setLoading(true)
    narration.continue(yourParams)
        .then((result) => {
            setUpdate((p) => p + 1)
            setLoading(false)
            if (result) {
                // your code
            }
        })
        .catch((e) => {
            setLoading(false)
            console.error(e)
        })
}
```

***

currentLabel [#currentlabel]

\> `readonly` **currentLabel**: [`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract)\<`any`, \{ }, `number`> | `undefined`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:59](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L59)

currentLabel is the current label that occurred during the progression of the steps.

***

currentStepTimesCounter [#currentsteptimescounter]

\> **currentStepTimesCounter**: `number`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:27](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L27)

Counter of execution times of the current step. Current execution is also included. Starts from 1.

**Attention**: if the step index is edited or the code of step is edited, the counter will be reset.

You can restart the counter in this way:

```typescript
narration.currentStepTimesCounter = 0
```

***

dialogGlue [#dialogglue]

\> **dialogGlue**: `boolean`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:274](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L274)

If true, the next dialogue text will be added to the current dialogue text.

***

inputType [#inputtype]

\> `readonly` **inputType**: `string` | `undefined`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:283](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L283)

***

inputValue [#inputvalue]

\> **inputValue**: [`StorageElementType`](/jsdoc/pixi-vn/index/type-aliases/StorageElementType)

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:278](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L278)

The input value to be inserted by the player.

***

isCurrentStepAlreadyOpened [#iscurrentstepalreadyopened]

\> `readonly` **isCurrentStepAlreadyOpened**: `boolean`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:87](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L87)

Check if the current step is already completed.

Returns [#returns-3]

True if the current step is already completed.

***

isRequiredInput [#isrequiredinput]

\> `readonly` **isRequiredInput**: `boolean`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:282](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L282)

If true, the player must enter a value.

***

openedLabels [#openedlabels]

\> `readonly` **openedLabels**: [`OpenedLabel`](/jsdoc/pixi-vn/index/interfaces/OpenedLabel)\[]

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:55](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L55)

The stack of the opened labels.

***

stepCounter [#stepcounter]

\> `readonly` **stepCounter**: `number`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:51](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L51)

This counter corresponds to the total number of steps that have been executed so far.

**Not is the history.stepsHistory.length - 1.**

Accessors [#accessors]

choices [#choices]

Get Signature [#get-signature]

\> **get** **choices**(): [`StoredIndexedChoiceInterface`](/jsdoc/pixi-vn/index/type-aliases/StoredIndexedChoiceInterface)\[] | `undefined`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:255](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L255)

The options to be shown in the game

Example [#example-1]

```typescript
narration.choices = [
    newChoiceOption("Events Test", EventsTestLabel, {}),
    newChoiceOption("Show Image Test", ShowImageTest, { image: "imageId" }, "call"),
    newChoiceOption("Ticker Test", TickerTestLabel, {}),
    newChoiceOption("Tinting Test", TintingTestLabel, {}, "jump"),
    newChoiceOption("Base Canvas Element Test", BaseCanvasElementTestLabel, {})
]
```

Returns [#returns-4]

[`StoredIndexedChoiceInterface`](/jsdoc/pixi-vn/index/type-aliases/StoredIndexedChoiceInterface)\[] | `undefined`

Set Signature [#set-signature]

\> **set** **choices**(`data`): `void`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:270](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L270)

The options to be shown in the game

Throws [#throws]

when a choice contains functions or class instances that cannot be serialized to JSON.

Example [#example-2]

```typescript
narration.choices = [
    newChoiceOption("Events Test", EventsTestLabel, {}),
    newChoiceOption("Show Image Test", ShowImageTest, { image: "imageId" }, "call"),
    newChoiceOption("Ticker Test", TickerTestLabel, {}),
    newChoiceOption("Tinting Test", TintingTestLabel, {}, "jump"),
    newChoiceOption("Base Canvas Element Test", BaseCanvasElementTestLabel, {})
]
```

Parameters [#parameters-1]

data [#data]

[`StoredChoiceInterface`](/jsdoc/pixi-vn/index/type-aliases/StoredChoiceInterface)\[] | `undefined`

Returns [#returns-5]

`void`

***

dialogue [#dialogue]

Get Signature [#get-signature-1]

\> **get** **dialogue**(): [`DialogueInterface`](/jsdoc/pixi-vn/index/interfaces/DialogueInterface) | `undefined`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:236](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L236)

Dialogue to be shown in the game

Returns [#returns-6]

[`DialogueInterface`](/jsdoc/pixi-vn/index/interfaces/DialogueInterface) | `undefined`

Set Signature [#set-signature-1]

\> **set** **dialogue**(`props`): `void`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:241](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L241)

Dialogue to be shown in the game

Throws [#throws-1]

when the dialogue contains functions or class instances that cannot be serialized to JSON.

Parameters [#parameters-2]

props [#props-1]

`string` | `string`\[] | [`DialogueInterface`](/jsdoc/pixi-vn/index/interfaces/DialogueInterface) | `undefined`

Returns [#returns-7]

`void`

Methods [#methods]

addCurrentStepToHistory() [#addcurrentsteptohistory]

\> **addCurrentStepToHistory**(): `void`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:102](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L102)

Save the current step to the history.

Returns [#returns-8]

`void`

***

call() [#call]

\> **call**\<`T`>(`label`, `props`): `Promise`\<[`StepLabelResultType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelResultType)>

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:173](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L173)

Execute the label and add it to the history. (It's similar to Ren'Py's call function)

Type Parameters [#type-parameters]

T [#t]

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

Parameters [#parameters-3]

label [#label]

`string` | [`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract)\<`any`, `T`, `number`>

The label to execute or the id of the label

props [#props-2]

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

The props to pass to the label.

Returns [#returns-9]

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

StepLabelResultType or undefined.

Throws [#throws-2]

when the label is not found in the registered labels.

Examples [#examples]

```typescript
narration.call(startLabel, yourParams).then((result) => {
    if (result) {
        // your code
    }
})
```

```typescript
// if you use it in a step label you should return the result.
return narration.call(startLabel).then((result) => {
    return result
})
```

***

clear() [#clear]

\> **clear**(): `void`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:298](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L298)

Clear all narration data

Returns [#returns-10]

`void`

***

closeAllLabels() [#closealllabels]

\> **closeAllLabels**(): `void`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:71](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L71)

Close all labels and add them to the history. &#x2A;*Attention: This method can cause an unhandled game ending.**

Returns [#returns-11]

`void`

***

closeCurrentLabel() [#closecurrentlabel]

\> **closeCurrentLabel**(): `void`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:67](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L67)

Close the current label and add it to the history.

Returns [#returns-12]

`void`

***

export() [#export]

\> **export**(): [`NarrationGameState`](/jsdoc/pixi-vn/index/interfaces/NarrationGameState)

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:306](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L306)

Export the narration to an object.

Returns [#returns-13]

[`NarrationGameState`](/jsdoc/pixi-vn/index/interfaces/NarrationGameState)

The narration in an object.

***

getRandomNumber() [#getrandomnumber]

\> **getRandomNumber**(`min`, `max`, `options?`): `number` | `undefined`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:35](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L35)

Get a random number between min and max.

Parameters [#parameters-4]

min [#min]

`number`

The minimum number.

max [#max]

`number`

The maximum number.

options? [#options-1]

The options.

onceOnly? [#onceonly]

`boolean`

If true, the number will be generated only once on the current step of the label.

**Default**

```ts
false
```

Returns [#returns-14]

`number` | `undefined`

The random number or undefined. If options.onceonly is true and all numbers between min and max have already been generated, it will return undefined.

***

getTimesChoiceMade() [#gettimeschoicemade]

\> **getTimesChoiceMade**(`index`): `number`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:98](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L98)

Get times a choice has been made in the current step.

Parameters [#parameters-5]

index [#index]

`number`

The index of the choice.

Returns [#returns-15]

`number`

The number of times the choice has been made.

***

getTimesLabelOpened() [#gettimeslabelopened]

\> **getTimesLabelOpened**(`label`): `number`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:92](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L92)

Get times a label has been opened

Parameters [#parameters-6]

label [#label-1]

`string`

Returns [#returns-16]

`number`

times a label has been opened

***

isLabelAlreadyCompleted() [#islabelalreadycompleted]

\> **isLabelAlreadyCompleted**(`label`): `boolean`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:77](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L77)

Check if the label is already completed.

Parameters [#parameters-7]

label [#label-2]

`string` | [`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract)\<`any`, \{ }, `number`>

The label to check.

Returns [#returns-17]

`boolean`

True if the label is already completed.

***

jump() [#jump]

\> **jump**\<`T`>(`label`, `props`): `Promise`\<[`StepLabelResultType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelResultType)>

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:199](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L199)

Execute the label, close the current label, execute the new label and add the new label to the history. (It's similar to Ren'Py's jump function)

Type Parameters [#type-parameters-1]

T [#t-1]

`T` *extends* `object`

Parameters [#parameters-8]

label [#label-3]

`string` | [`LabelAbstract`](/jsdoc/pixi-vn/index/classes/LabelAbstract)\<`any`, `T`, `number`>

The label to execute.

props [#props-3]

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

The props to pass to the label or the id of the label

Returns [#returns-18]

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

StepLabelResultType or undefined.

Throws [#throws-3]

when the label is not found in the registered labels.

Examples [#examples-1]

```typescript
narration.jump(startLabel, yourParams).then((result) => {
    if (result) {
        // your code
    }
})
```

```typescript
// if you use it in a step label you should return the result.
return narration.jump(startLabel).then((result) => {
    return result
})
```

***

removeInputRequest() [#removeinputrequest]

\> **removeInputRequest**(): `void`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:293](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L293)

Remove the input request.

Returns [#returns-19]

`void`

***

requestInput() [#requestinput]

\> **requestInput**(`info`, `defaultValue?`): `void`

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:289](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L289)

Request input from the player.

Parameters [#parameters-9]

info [#info]

`Omit`\<[`InputInfo`](/jsdoc/pixi-vn/index/type-aliases/InputInfo), `"isRequired"`>

The input value to be inserted by the player.

defaultValue? [#defaultvalue]

[`StorageElementType`](/jsdoc/pixi-vn/index/type-aliases/StorageElementType)

The default value to be inserted.

Returns [#returns-20]

`void`

***

restore() [#restore]

\> **restore**(`data`, `lastHistoryStep`): `Promise`\<`void`>

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:311](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L311)

Restore the narration from an object.

Parameters [#parameters-10]

data [#data-1]

`object`

The narration in an object.

lastHistoryStep [#lasthistorystep]

`Omit`\<[`HistoryStep`](/jsdoc/pixi-vn/index/interfaces/HistoryStep), `"diff"`> | `null`

Returns [#returns-21]

`Promise`\<`void`>

***

selectChoice() [#selectchoice]

\> **selectChoice**\<`T`>(`item`, `props`): `Promise`\<[`StepLabelResultType`](/jsdoc/pixi-vn/index/type-aliases/StepLabelResultType)>

Defined in: [src/narration/interfaces/NarrationManagerInterface.ts:224](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/narration/interfaces/NarrationManagerInterface.ts#L224)

Select a choice from the choice menu. and close the choice menu.

Type Parameters [#type-parameters-2]

T [#t-2]

`T` *extends* `object`

Parameters [#parameters-11]

item [#item]

[`StoredIndexedChoiceInterface`](/jsdoc/pixi-vn/index/type-aliases/StoredIndexedChoiceInterface)

props [#props-4]

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

Returns [#returns-22]

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

Throws [#throws-4]

when the choice type is not `"call"`, `"jump"`, or `"close"`.

Example [#example-3]

```typescript
narration.selectChoice(item, {
    navigate: navigate,
    // your props
    ...item.props
})
    .then(() => {
        // your code
    })
    .catch((e) => {
        // your code
    })
```
