dialogue
dialogue
The dialogue class represents complete interactive dialogue sequences, NPC cutscenes, and narrative event graphs. Supports adding narrative captions, player choices, conditions, camera panning, and starting the dialogue UI screen.
Overview
Properties (6)
| Property | Type | Summary |
|---|---|---|
count
|
number
|
Total count of steps in the dialogue. |
isOpen
|
boolean
|
Alias for isShowing. |
isShowing
|
boolean
|
Checks if the dialogue is currently being shown. |
startStep
|
dialoguestep
|
The starting step of the dialogue. |
stepCount
|
number
|
Alias for count. |
steps
|
table
|
Table of all dialogue steps. |
Methods (25)
| Method Signature | Returns | Summary |
|---|---|---|
dialogue:addCamera(target)
|
dialoguestep
|
Adds a camera panning step. |
dialogue:addCondition(script, [trueTarget], [falseTarget])
|
dialoguestep
|
Adds a conditional branch step. |
dialogue:addDelay(seconds)
|
dialoguestep
|
Adds a timed pause/delay step. |
dialogue:addEntity(entity, text)
|
dialoguestep
|
Adds an NPC dialogue line step. |
dialogue:addMusic(media)
|
dialoguestep
|
Adds a background music change step. |
dialogue:addNarrative(text)
|
dialoguestep
|
Adds a narrative text step. |
dialogue:addPlayer(text)
|
dialoguestep
|
Adds a player dialogue line step. |
dialogue:addRadio(entity, text)
|
dialoguestep
|
Adds a radio transmission dialogue step. |
dialogue:addRandom()
|
dialoguestep
|
Adds a random branch step. |
dialogue:addStep(stepVal, [textVal], [entityVal])
|
dialoguestep
|
Adds a step to the dialogue sequence. |
dialogue:addSwitch(script)
|
dialoguestep
|
Adds a multi-branch switch step. |
dialogue:chain(...)
|
dialogue
|
Chains multiple steps sequentially in order. |
dialogue:clear()
|
void
|
Clears all steps from the dialogue. |
dialogue.close()
|
void
|
Closes any currently active dialogue screen. |
dialogue:connect(fromVal, toVal)
|
dialogue
|
Connects the output of one step to another. |
dialogue.getCurrent()
|
dialogue
|
Returns the currently displayed dialogue. |
dialogue:getStep(index)
|
dialoguestep
|
Gets a step by 1-based index. |
dialogue:getStepByTitle(title)
|
dialoguestep
|
Finds a step by its title. |
dialogue:indexOf(step)
|
number
|
Finds the index of a step. |
dialogue:insertStep(index, stepVal, [textVal], [entityVal])
|
dialoguestep
|
Inserts a step at the specified index. |
dialogue.isDisplayed()
|
boolean
|
Static check if a dialogue screen is currently open. |
dialogue.new([stepsTable])
|
dialogue
|
Constructs a new dialogue container. |
dialogue:removeStep(stepOrIndex)
|
boolean
|
Removes a step from the dialogue. |
dialogue:resolveConnections()
|
void
|
Resolves object references into internal step index connections. |
dialogue:show([arg1], [arg2])
|
dialogue
|
Displays and begins dialogue playback on screen. |
Detailed Reference
dialogue.countnumberTotal number of steps.
Returns the number of steps.
dialogue.isOpenbooleanTrue if open.
Checks if dialogue is open.
dialogue.isShowingbooleanTrue if dialogue screen is open.
Returns true if the dialogue UI is open and displaying.
dialogue.startStepdialoguestepThe initial step.
Gets or sets the first step to display when dialogue opens.
dialogue.stepCountnumberTotal number of steps.
Returns total step count.
dialogue.stepstable1-based array of dialoguestep objects.
Returns an array of all dialogue step objects.
dialogue:addCamera(target)| Parameter | Type | Default | Description |
|---|---|---|---|
target | entity|vector3 | Target entity or 3D coordinate. |
dialoguestepCreated step.
Appends a step that pans the camera toward target.
dialogue:addCondition(script, [trueTarget], [falseTarget])| Parameter | Type | Default | Description |
|---|---|---|---|
script | string | Condition script returning boolean. | |
trueTarget | dialoguestep|number | optional | Step if true. |
falseTarget | dialoguestep|number | optional | Step if false. |
dialoguestepCreated step.
Appends an if/else conditional branch step.
dialogue:addDelay(seconds)| Parameter | Type | Default | Description |
|---|---|---|---|
seconds | number | Pause duration in seconds. |
dialoguestepCreated step.
Appends a timed delay step.
dialogue:addEntity(entity, text)| Parameter | Type | Default | Description |
|---|---|---|---|
entity | entity|number | Speaking entity or ID. | |
text | string | NPC speech line. |
dialoguestepCreated step.
Appends a speech step spoken by an NPC entity.
dialogue:addMusic(media)| Parameter | Type | Default | Description |
|---|---|---|---|
media | string | Audio stream resource path. |
dialoguestepCreated step.
Appends a step that triggers music playback.
dialogue:addNarrative(text)| Parameter | Type | Default | Description |
|---|---|---|---|
text | string | Narrative caption text. |
dialoguestepCreated step.
Appends a narrative text caption step.
dialogue:addPlayer(text)| Parameter | Type | Default | Description |
|---|---|---|---|
text | string | Player dialogue text. |
dialoguestepCreated step.
Appends a speech step spoken by the player.
dialogue:addRadio(entity, text)| Parameter | Type | Default | Description |
|---|---|---|---|
entity | entity|number | Radio transmission source. | |
text | string | Radio transmission message. |
dialoguestepCreated step.
Appends a radio/intercom message step.
dialogue:addRandom()dialoguestepCreated step.
Appends a step that randomly branches among its options.
dialogue:addStep(stepVal, [textVal], [entityVal])| Parameter | Type | Default | Description |
|---|---|---|---|
stepVal | dialoguestep|table|number | Step object or config table. | |
textVal | string | "" | Text line. |
entityVal | entity|number | optional | Speaking entity. |
dialoguestepAdded step.
Appends a step to the dialogue.
dialogue:addSwitch(script)| Parameter | Type | Default | Description |
|---|---|---|---|
script | string | Lua expression returning branch key. |
dialoguestepCreated step.
Appends a switch branch step evaluated by script.
dialogue:chain(...)| Parameter | Type | Default | Description |
|---|---|---|---|
... | dialoguestep|table | Sequential steps or table of steps. |
dialogueSelf for fluent chaining.
Connects all passed steps one after the other in linear sequence.
dlg:chain(step1, step2, step3)dialogue:clear()Empties the dialogue sequence.
dialogue.close()Terminates active dialogue playback and closes the UI.
dialogue:connect(fromVal, toVal)| Parameter | Type | Default | Description |
|---|---|---|---|
fromVal | dialoguestep|number | Source step. | |
toVal | dialoguestep|number | Destination step. |
dialogueSelf for fluent chaining.
Wires step fromVal to transition to toVal.
dlg:connect(step1, step2)dialogue.getCurrent()dialogueActive dialogue or nil.
Gets active dialogue instance.
dialogue:getStep(index)| Parameter | Type | Default | Description |
|---|---|---|---|
index | number | 1-based step index. |
dialoguestepStep or nil.
Retrieves step at index.
dialogue:getStepByTitle(title)| Parameter | Type | Default | Description |
|---|---|---|---|
title | string | Step title label. |
dialoguestepMatching step or nil.
Searches steps for a title match.
dialogue:indexOf(step)| Parameter | Type | Default | Description |
|---|---|---|---|
step | dialoguestep | Target step. |
number1-based index, or 0 if not found.
Returns 1-based index of step.
dialogue:insertStep(index, stepVal, [textVal], [entityVal])| Parameter | Type | Default | Description |
|---|---|---|---|
index | number | 1-based insertion index. | |
stepVal | dialoguestep|table|number | Step object or type. | |
textVal | string | "" | Text line. |
entityVal | entity|number | optional | Speaking entity. |
dialoguestepInserted step.
Inserts a step into the dialogue sequence at index.
dialogue.isDisplayed()booleanTrue if dialogue screen is active.
Returns true if any dialogue is being displayed.
dialogue.new([stepsTable])| Parameter | Type | Default | Description |
|---|---|---|---|
stepsTable | table | {} | Array of initial steps. |
dialogueNew dialogue instance.
Creates an empty dialogue container.
local dlg = dialogue.new()dialogue:removeStep(stepOrIndex)| Parameter | Type | Default | Description |
|---|---|---|---|
stepOrIndex | dialoguestep|number | Step object or 1-based index. |
booleanTrue if removed.
Deletes the specified step from dialogue.
dialogue:resolveConnections()Translates step target object pointers into internal integer step indices.
dialogue:show([arg1], [arg2])| Parameter | Type | Default | Description |
|---|---|---|---|
arg1 | dialoguestep|number|function | optional | Starting step or onEnd callback. |
arg2 | dialoguestep|number|function | optional | Starting step or onEnd callback. |
dialogueSelf.
Opens the dialogue screen and begins playback.
dlg:show(function(d, s)
print("Dialogue concluded!")
end)