Dev » Lua API » dialogue
← Back to all classes

dialogue

Dialogue 6 Properties 25 Methods

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

# count PROPERTY
dialogue.count
Total count of steps in the dialogue.
Parameters
None
Returns
number

Total number of steps.

Description

Returns the number of steps.

# isOpen PROPERTY
dialogue.isOpen
Alias for isShowing.
Parameters
None
Returns
boolean

True if open.

Description

Checks if dialogue is open.

# isShowing PROPERTY
dialogue.isShowing
Checks if the dialogue is currently being shown.
Parameters
None
Returns
boolean

True if dialogue screen is open.

Description

Returns true if the dialogue UI is open and displaying.

# startStep PROPERTY
dialogue.startStep
The starting step of the dialogue.
Parameters
None
Returns
dialoguestep

The initial step.

Description

Gets or sets the first step to display when dialogue opens.

# stepCount PROPERTY
dialogue.stepCount
Alias for count.
Parameters
None
Returns
number

Total number of steps.

Description

Returns total step count.

# steps PROPERTY
dialogue.steps
Table of all dialogue steps.
Parameters
None
Returns
table

1-based array of dialoguestep objects.

Description

Returns an array of all dialogue step objects.

# addCamera METHOD
dialogue:addCamera(target)
Adds a camera panning step.
Parameters
ParameterTypeDefaultDescription
targetentity|vector3

Target entity or 3D coordinate.

Returns
dialoguestep

Created step.

Description

Appends a step that pans the camera toward target.

# addCondition METHOD
dialogue:addCondition(script, [trueTarget], [falseTarget])
Adds a conditional branch step.
Parameters
ParameterTypeDefaultDescription
scriptstring

Condition script returning boolean.

trueTargetdialoguestep|numberoptional

Step if true.

falseTargetdialoguestep|numberoptional

Step if false.

Returns
dialoguestep

Created step.

Description

Appends an if/else conditional branch step.

# addDelay METHOD
dialogue:addDelay(seconds)
Adds a timed pause/delay step.
Parameters
ParameterTypeDefaultDescription
secondsnumber

Pause duration in seconds.

Returns
dialoguestep

Created step.

Description

Appends a timed delay step.

# addEntity METHOD
dialogue:addEntity(entity, text)
Adds an NPC dialogue line step.
Parameters
ParameterTypeDefaultDescription
entityentity|number

Speaking entity or ID.

textstring

NPC speech line.

Returns
dialoguestep

Created step.

Description

Appends a speech step spoken by an NPC entity.

# addMusic METHOD
dialogue:addMusic(media)
Adds a background music change step.
Parameters
ParameterTypeDefaultDescription
mediastring

Audio stream resource path.

Returns
dialoguestep

Created step.

Description

Appends a step that triggers music playback.

# addNarrative METHOD
dialogue:addNarrative(text)
Adds a narrative text step.
Parameters
ParameterTypeDefaultDescription
textstring

Narrative caption text.

Returns
dialoguestep

Created step.

Description

Appends a narrative text caption step.

# addPlayer METHOD
dialogue:addPlayer(text)
Adds a player dialogue line step.
Parameters
ParameterTypeDefaultDescription
textstring

Player dialogue text.

Returns
dialoguestep

Created step.

Description

Appends a speech step spoken by the player.

# addRadio METHOD
dialogue:addRadio(entity, text)
Adds a radio transmission dialogue step.
Parameters
ParameterTypeDefaultDescription
entityentity|number

Radio transmission source.

textstring

Radio transmission message.

Returns
dialoguestep

Created step.

Description

Appends a radio/intercom message step.

# addRandom METHOD
dialogue:addRandom()
Adds a random branch step.
Parameters
None
Returns
dialoguestep

Created step.

Description

Appends a step that randomly branches among its options.

# addStep METHOD
dialogue:addStep(stepVal, [textVal], [entityVal])
Adds a step to the dialogue sequence.
Parameters
ParameterTypeDefaultDescription
stepValdialoguestep|table|number

Step object or config table.

textValstring""

Text line.

entityValentity|numberoptional

Speaking entity.

Returns
dialoguestep

Added step.

Description

Appends a step to the dialogue.

# addSwitch METHOD
dialogue:addSwitch(script)
Adds a multi-branch switch step.
Parameters
ParameterTypeDefaultDescription
scriptstring

Lua expression returning branch key.

Returns
dialoguestep

Created step.

Description

Appends a switch branch step evaluated by script.

# chain METHOD
dialogue:chain(...)
Chains multiple steps sequentially in order.
Parameters
ParameterTypeDefaultDescription
...dialoguestep|table

Sequential steps or table of steps.

Returns
dialogue

Self for fluent chaining.

Description

Connects all passed steps one after the other in linear sequence.

dlg:chain(step1, step2, step3)
# clear METHOD
dialogue:clear()
Clears all steps from the dialogue.
Parameters
None
Returns
None (void)
Description

Empties the dialogue sequence.

# close METHOD
dialogue.close()
Closes any currently active dialogue screen.
Parameters
None
Returns
None (void)
Description

Terminates active dialogue playback and closes the UI.

# connect METHOD
dialogue:connect(fromVal, toVal)
Connects the output of one step to another.
Parameters
ParameterTypeDefaultDescription
fromValdialoguestep|number

Source step.

toValdialoguestep|number

Destination step.

Returns
dialogue

Self for fluent chaining.

Description

Wires step fromVal to transition to toVal.

dlg:connect(step1, step2)
# getCurrent METHOD
dialogue.getCurrent()
Returns the currently displayed dialogue.
Parameters
None
Returns
dialogue

Active dialogue or nil.

Description

Gets active dialogue instance.

# getStep METHOD
dialogue:getStep(index)
Gets a step by 1-based index.
Parameters
ParameterTypeDefaultDescription
indexnumber

1-based step index.

Returns
dialoguestep

Step or nil.

Description

Retrieves step at index.

# getStepByTitle METHOD
dialogue:getStepByTitle(title)
Finds a step by its title.
Parameters
ParameterTypeDefaultDescription
titlestring

Step title label.

Returns
dialoguestep

Matching step or nil.

Description

Searches steps for a title match.

# indexOf METHOD
dialogue:indexOf(step)
Finds the index of a step.
Parameters
ParameterTypeDefaultDescription
stepdialoguestep

Target step.

Returns
number

1-based index, or 0 if not found.

Description

Returns 1-based index of step.

# insertStep METHOD
dialogue:insertStep(index, stepVal, [textVal], [entityVal])
Inserts a step at the specified index.
Parameters
ParameterTypeDefaultDescription
indexnumber

1-based insertion index.

stepValdialoguestep|table|number

Step object or type.

textValstring""

Text line.

entityValentity|numberoptional

Speaking entity.

Returns
dialoguestep

Inserted step.

Description

Inserts a step into the dialogue sequence at index.

# isDisplayed METHOD
dialogue.isDisplayed()
Static check if a dialogue screen is currently open.
Parameters
None
Returns
boolean

True if dialogue screen is active.

Description

Returns true if any dialogue is being displayed.

# new METHOD
dialogue.new([stepsTable])
Constructs a new dialogue container.
Parameters
ParameterTypeDefaultDescription
stepsTabletable{}

Array of initial steps.

Returns
dialogue

New dialogue instance.

Description

Creates an empty dialogue container.

local dlg = dialogue.new()
# removeStep METHOD
dialogue:removeStep(stepOrIndex)
Removes a step from the dialogue.
Parameters
ParameterTypeDefaultDescription
stepOrIndexdialoguestep|number

Step object or 1-based index.

Returns
boolean

True if removed.

Description

Deletes the specified step from dialogue.

# resolveConnections METHOD
dialogue:resolveConnections()
Resolves object references into internal step index connections.
Parameters
None
Returns
None (void)
Description

Translates step target object pointers into internal integer step indices.

# show METHOD
dialogue:show([arg1], [arg2])
Displays and begins dialogue playback on screen.
Parameters
ParameterTypeDefaultDescription
arg1dialoguestep|number|functionoptional

Starting step or onEnd callback.

arg2dialoguestep|number|functionoptional

Starting step or onEnd callback.

Returns
dialogue

Self.

Description

Opens the dialogue screen and begins playback.

dlg:show(function(d, s)
    print("Dialogue concluded!")
end)