Skip to content

LSDE Dialog Engine / LsdeUtils

Class: LsdeUtils

Defined in: lsde-utils.ts:8

Public utility class exposing common helpers for game developers integrating the LSDE engine.

Constructors

Constructor

new LsdeUtils(): LsdeUtils

Returns

LsdeUtils

Properties

evaluateConditionChain

static evaluateConditionChain: (conditions, evaluator) => boolean

Defined in: lsde-utils.ts:75

Evaluates a chain of conditions with & (AND) / | (OR) chaining. Left-to-right evaluation, no operator precedence. Empty array returns true.

Evaluate a chain of conditions left-to-right with no operator precedence.

  • Empty array → true (no conditions = pass)
  • First condition: standalone result
  • Subsequent conditions: '&' = AND, '|' = OR with accumulated result

Parameters

conditions

ExportCondition[]

evaluator

(condition) => boolean

Returns

boolean

Param

The condition chain to evaluate.

Param

A callback that evaluates a single condition.


evaluateConditionGroups

static evaluateConditionGroups: (groups, evaluator, dispatcher?) => number | number[]

Defined in: lsde-utils.ts:85

Evaluates condition groups (2D array) for switch or dispatcher mode.

  • Switch mode (dispatcher = false): returns the index of the first matching group, or -1.
  • Dispatcher mode (dispatcher = true): returns an array of all matching group indices.

Evaluate condition groups (2D array) for switch or dispatcher mode. Each inner array is a "case" evaluated via evaluateConditionChain.

  • Switch mode (dispatcher = false): evaluates groups in order, returns the index of the first matching group, or -1 if none match (→ default port).
  • Dispatcher mode (dispatcher = true): evaluates ALL groups, returns an array of all matching indices (may be empty → default port only).

Parameters

groups

ExportCondition[][]

evaluator

(condition) => boolean

dispatcher?

boolean

Returns

number | number[]

Param

The 2D condition array from ConditionBlock.conditions.

Param

A callback that evaluates a single condition.

Param

When true, evaluates all groups instead of breaking at first match.


filterVisibleChoices

static filterVisibleChoices: (choices, evaluator, scene?) => ChoiceItem[]

Defined in: lsde-utils.ts:96

Filters choice items by their visibility conditions. Choices without visibilityConditions are always visible.

Filter choices by their visibilityConditions. Choices with no conditions or passing conditions are kept.

When scene is provided, choice: conditions are resolved automatically via the scene's internal choice history — the developer never sees them. Non-choice conditions are delegated to the evaluator callback.

Parameters

choices

ChoiceItem[]

evaluator

(condition) => boolean

scene?
evaluateCondition

Returns

ChoiceItem[]

Param

The full list of choices.

Param

A callback that evaluates a single condition.

Param

Optional SceneHandle. When provided, choice: conditions are resolved automatically via the scene's internal choice history and the developer never sees them — only non-choice conditions are delegated to the evaluator callback.


isActionBlock

static isActionBlock: (block) => block is ActionBlock

Defined in: lsde-utils.ts:22

Returns true if the block is an ActionBlock.

Parameters

block

BlueprintBlock

Returns

block is ActionBlock


isChoiceBlock

static isChoiceBlock: (block) => block is ChoiceBlock

Defined in: lsde-utils.ts:18

Returns true if the block is a ChoiceBlock.

Parameters

block

BlueprintBlock

Returns

block is ChoiceBlock


isConditionBlock

static isConditionBlock: (block) => block is ConditionBlock

Defined in: lsde-utils.ts:20

Returns true if the block is a ConditionBlock.

Parameters

block

BlueprintBlock

Returns

block is ConditionBlock


isDialogBlock

static isDialogBlock: (block) => block is DialogBlock

Defined in: lsde-utils.ts:16

Returns true if the block is a DialogBlock.

Parameters

block

BlueprintBlock

Returns

block is DialogBlock


isNoteBlock

static isNoteBlock: (block) => block is NoteBlock

Defined in: lsde-utils.ts:24

Returns true if the block is a NoteBlock.

Parameters

block

BlueprintBlock

Returns

block is NoteBlock


locale

static locale: string | null = null

Defined in: lsde-utils.ts:11

Current locale set by engine.setLocale(). Used as default by getLocalizedText().

Methods

getBlockLabel()

static getBlockLabel(block): string

Defined in: lsde-utils.ts:29

Returns the block's label, or the first 8 characters of its UUID as fallback.

Parameters

block

BlueprintBlock

Returns

string


getChoiceConditionBlockUuid()

static getChoiceConditionBlockUuid(condition): string | undefined

Defined in: lsde-utils.ts:65

Extracts the referenced choice block UUID from a choice condition.

Parameters

condition

ExportCondition

Returns

string | undefined

The block UUID, or undefined if the condition is not a choice condition.


getLocalizedText()

static getLocalizedText(dialogueText, locale?): string | undefined

Defined in: lsde-utils.ts:42

Looks up a localized text value from a dialogueText map. Works with both DialogBlock.dialogueText and ChoiceItem.dialogueText. Uses the engine locale (set via engine.setLocale()) by default.

Parameters

dialogueText

Record<string, string> | undefined

The localized text map.

locale?

string

Optional locale override. If omitted, uses LsdeUtils.locale.

Returns

string | undefined

The localized string, or undefined if the key is not found.

Throws

If no locale is set (neither via parameter nor engine.setLocale()).


isChoiceCondition()

static isChoiceCondition(condition): boolean

Defined in: lsde-utils.ts:57

Returns true if the condition references a previous choice selection. Choice conditions use the key format "choice:<blockUuid>" and are evaluated internally by the engine against the scene's choice history.

Parameters

condition

ExportCondition

Returns

boolean