Skip to content

Dialog

Dialog helpers for Lilia NPC conversations, generated dialog trees, NPC configuration menus, and client synchronization.


Overview

The dialog library centralizes NPC dialog registration, generated dialog tree storage, faction-gated dialog nodes, NPC customization workflows, and clientside dialog configuration interfaces under `lia.dialog`.

lia.dialog.isTableEqual(tbl1, tbl2, checked)View Source

Purpose

Recursively compares two tables for matching keys and values while preventing infinite loops from cyclic references.

Realm

Shared

Parameters

table tbl1 The first table to compare.

table tbl2 The second table to compare.

table checked optional Internal table used to track tables that have already been compared.

Returns

boolean True when both tables contain equivalent values, otherwise false.

Example Usage

  local same = lia.dialog.isTableEqual(firstTable, secondTable)

lia.dialog.registerConfiguration(uniqueID, data)View Source

Purpose

Registers or updates an NPC configuration entry used by the NPC configuration picker.

Realm

Shared

Parameters

string uniqueID Unique identifier for the configuration entry.

table data Configuration metadata such as name, description, order, visibility checks, and open/apply callbacks.

Returns

table|nil The registered configuration table, or nil if the identifier is invalid.

Example Usage

  lia.dialog.registerConfiguration("appearance", {
      name = "@npcConfigAppearanceName",
      order = 0
  })

lia.dialog.getConfiguration(uniqueID)View Source

Purpose

Returns a registered NPC configuration by unique identifier.

Realm

Shared

Parameters

string uniqueID The unique configuration identifier to fetch.

Returns

table|nil The configuration table when registered, otherwise nil.

Example Usage

  local config = lia.dialog.getConfiguration("appearance")

lia.dialog.resolveDialogTypeIdentifier(value)View Source

Purpose

Resolves a dialog type value to its stored unique identifier, accepting either an identifier or a localized display name.

Realm

Shared

Parameters

string value The dialog identifier, localized display name, empty value, or `none` marker to resolve.

Returns

string The matching stored dialog identifier when found, otherwise the original value.

Example Usage

  local uniqueID = lia.dialog.resolveDialogTypeIdentifier(selection)

lia.dialog.isGeneratedDialogSelection(value)View Source

Purpose

Checks whether a value represents the special custom dialog selection entry.

Realm

Shared

Parameters

any value The value to compare against the generated dialog selection identifier.

Returns

boolean True when the value matches the custom dialog selection identifier, otherwise false.

Example Usage

  if lia.dialog.isGeneratedDialogSelection(dialogType) then return end

lia.dialog.isDialogNPCEntity(npcOrClass)View Source

Purpose

Checks whether an entity or class name represents a Lilia dialog NPC entity.

Realm

Shared

Parameters

Entity|string npcOrClass The entity instance or class name to inspect.

Returns

boolean True when the entity or class is `lia_npc`, otherwise false.

Example Usage

  if lia.dialog.isDialogNPCEntity(ent) then return true end

lia.dialog.entityUsesGeneratedDialog(npc)View Source

Purpose

Checks whether a valid NPC is currently assigned to a generated dialog tree.

Realm

Shared

Parameters

Entity npc The NPC entity to inspect.

Returns

boolean True when the NPC's dialog data contains `GeneratedDialog`, otherwise false.

Example Usage

  local usesGenerated = lia.dialog.entityUsesGeneratedDialog(npc)

lia.dialog.isGeneratedDialogData(data)View Source

Purpose

Checks whether dialog data contains a generated node-based dialog tree.

Realm

Shared

Parameters

table data The dialog data table to inspect.

Returns

boolean True when the table has a `GeneratedDialog` table, otherwise false.

Example Usage

  if lia.dialog.isGeneratedDialogData(data) then return end

lia.dialog.isConversationDialogData(data)View Source

Purpose

Checks whether dialog data contains a standard conversation table.

Realm

Shared

Parameters

table data The dialog data table to inspect.

Returns

boolean True when the table has a `Conversation` table, otherwise false.

Example Usage

  if lia.dialog.isConversationDialogData(data) then return end

lia.dialog.isDialogCompatibleWithEntity(npc, data)View Source

Purpose

Checks whether dialog data can be used by a valid dialog NPC entity.

Realm

Shared

Parameters

Entity npc The NPC entity being configured or opened.

table data The dialog data to validate.

Returns

boolean True when the entity is a dialog NPC and the data is either conversation or generated dialog data.

Example Usage

  if lia.dialog.isDialogCompatibleWithEntity(npc, data) then return end

lia.dialog.getCompatibleDialogOptions(npc)View Source

Purpose

Builds the list of dialog type choices available for a dialog NPC.

Realm

Shared

Parameters

Entity npc The NPC entity to validate options against.

Returns

table A sorted list of `{displayName, uniqueID}` choices, followed by the custom dialog option.

Example Usage

  local options = lia.dialog.getCompatibleDialogOptions(npc)

lia.dialog.getNPCData(npcID)View Source

Purpose

Returns the registered server-side dialog data for an NPC dialog type.

Realm

Server

Parameters

string npcID The dialog type identifier to fetch.

Returns

table|nil The registered dialog data when available, otherwise nil.

Example Usage

  local data = lia.dialog.getNPCData(npcID)

lia.dialog.getOriginalNPCData(npcID)View Source

Purpose

Returns the original server-side NPC dialog data before client sanitization.

Realm

Server

Parameters

string npcID The dialog type identifier to fetch.

Returns

table|nil The original registered data table when available, otherwise nil.

Example Usage

  local originalData = lia.dialog.getOriginalNPCData(npcID)

lia.dialog.saveGeneratedDialogs()View Source

Purpose

Persists generated dialog trees to Lilia data storage.

Realm

Server

Returns

nil This function does not return a value.

Example Usage

  lia.dialog.saveGeneratedDialogs()

lia.dialog.loadGeneratedDialogs()View Source

Purpose

Loads generated dialog trees from Lilia data storage and registers them without immediately syncing.

Realm

Server

Returns

nil This function does not return a value.

Example Usage

  lia.dialog.loadGeneratedDialogs()

lia.dialog.syncToClients(client)View Source

Purpose

Synchronizes sanitized dialog data to one client or all clients when their dialog data hash changes.

Realm

Server

Parameters

Player client optional Optional target player. When nil, all players receive updated data if needed.

Returns

nil This function does not return a value.

Example Usage

  lia.dialog.syncToClients(client)

lia.dialog.syncDialogs()View Source

Purpose

Synchronizes dialog data to all connected clients.

Realm

Server

Returns

nil This function does not return a value.

Example Usage

  lia.dialog.syncDialogs()

lia.dialog.registerNPC(uniqueID, data, shouldSync)View Source

Purpose

Registers an NPC dialog type with conversation data or generated dialog data.

Realm

Server

Parameters

string uniqueID Unique dialog type identifier.

table data Dialog data containing either `Conversation` or `GeneratedDialog`.

boolean shouldSync optional Set to false to skip immediate synchronization after registration.

Returns

boolean True when registration succeeds, otherwise false.

Example Usage

  lia.dialog.registerNPC("example_npc", dialogData)

lia.dialog.openDialog(client, npc, npcID)View Source

Purpose

Validates, filters, sanitizes, and opens an NPC dialog for a player.

Realm

Server

Parameters

Player client The player opening the dialog.

Entity npc The NPC entity being opened.

string npcID The dialog type identifier assigned to the NPC.

Returns

nil This function does not return a value.

Example Usage

  lia.dialog.openDialog(client, npc, npcID)

lia.dialog.getNPCData(npcID)View Source

Purpose

Returns the clientside synchronized dialog data for an NPC dialog type.

Realm

Client

Parameters

string npcID The dialog type identifier to fetch.

Returns

table|nil The synchronized dialog data when available, otherwise nil.

Example Usage

  local data = lia.dialog.getNPCData(npcID)

lia.dialog.submitConfiguration(configID, npc, payload)View Source

Purpose

Submits an NPC configuration payload from the client to the server.

Realm

Client

Parameters

string configID The configuration identifier to apply.

Entity npc The NPC entity being configured.

table payload optional Configuration data to send to the server.

Returns

nil This function does not return a value.

Example Usage

  lia.dialog.submitConfiguration("appearance", npc, customData)

lia.dialog.openCustomizationUI(npc, configID)View Source

Purpose

Opens the NPC customization interface for appearance, animation, and dialog type selection.

Realm

Client

Parameters

Entity npc The NPC entity to customize.

string configID optional Configuration identifier to submit when applying changes. Defaults to `appearance`.

Returns

nil This function does not return a value.

Example Usage

  lia.dialog.openCustomizationUI(npc, "appearance")

lia.dialog.openNodeEditor(npc)View Source

Purpose

Opens the clientside generated dialog node editor for an NPC.

Realm

Client

Parameters

Entity npc The NPC entity whose generated dialog tree should be edited.

Returns

nil This function does not return a value.

Example Usage

  lia.dialog.openNodeEditor(npc)

lia.dialog.getAvailableConfigurations(ply, npc, npcID)View Source

Purpose

Returns NPC configuration entries visible to a player for the selected NPC.

Realm

Client

Parameters

Player ply The player viewing the configuration menu.

Entity npc The NPC entity being configured.

string npcID optional Optional dialog type identifier associated with the NPC.

Returns

table A sorted list of visible configuration tables.

Example Usage

  local configurations = lia.dialog.getAvailableConfigurations(LocalPlayer(), npc, npcID)

lia.dialog.openConfigurationPicker(npc, npcID)View Source

Purpose

Opens the best available NPC configuration UI and queues secondary configuration buttons when needed.

Realm

Client

Parameters

Entity npc The NPC entity being configured.

string npcID optional Optional dialog type identifier associated with the NPC.

Returns

nil This function does not return a value.

Example Usage

  lia.dialog.openConfigurationPicker(npc)

Hooks

Library-specific hooks documented for this library.


OnNPCTypeSet(client, npc, npcID, data)View Source

Purpose

Runs after a server resolves an NPC dialog type and before the sanitized dialog payload is sent to the client.

Realm

Server

Parameters

Player client The player opening the NPC dialog.

Entity npc The dialog NPC being opened.

string npcID The unique dialog type identifier assigned to the NPC.

table data The filtered and sanitized dialog data being sent to the client.