Module Dialogue

Dialogue provides the interface to the interactive dialogue feature of FTSE.

To use, include the module using Lua's "require" statement, saving the returned object:

Usage:

    speech=require "FTSE.modules.Dialogue"
    

Functions

LoadConversation (tag, file) The LoadConversation function will load a Lua file, and register it as a conversation.
RunNode (conv, node, npc, plyr) The RunNode function is used internally by FTSE to initiate transitions within the dialogue tree.

Helper functions for Choice conditions

skillcheck (skillparam, value) skillcheck is a shortcut function for the condition field in Choice objects, returning true if the squad member meets the given skill check.
skillnotmet (skillparam, value) skillnotmet is a shortcut function for the condition field in Choice objects, returning true if the squad member does not meet the given skill check.
campaignvar (var, value) campaignvar is a shortcut function for the condition field in Choice objects, returning true if the listed campaign variable has the given value.
missionvar (var, value) missionvar is a shortcut function for the condition field in Choice objects, returning true if the listed mission variable has the given value.

Dialogue object fields

conversations The conversations field is a table which includes all registered conversation objects.
text The text field is a string which indicates the NPC text to show in the FTSE Dialogue window.
audio The audio field is a string which indicates which audio file should be played, if any.
choices The choices field is an array which contains Choice type objects, indicating which dialogue choices will be presented to the player.
choicestack The choicestack field is an array which contains subtables of Choice objects, as a stack structure.

Dialogue object types

Node The Node type defines each node in a conversation tree.
Choice The Choice type defines a conversation choice which will be presented to the player.


Functions

LoadConversation (tag, file)
The LoadConversation function will load a Lua file, and register it as a conversation.

Parameters:

  • tag A tag string identifying the conversation. This tag must be included in a level as a "windowed" speech node, and assigned to an NPC's click speech.
  • file A string indicating the location of the file, in Lua "require" format. For example, if a conversation file named MyConv.lua is in the core\FTSE\Dialogue directory, the file string would be "FTSE.Dialogue.MyConv".

Returns:

    None.

Usage:

  • speech=require "FTSE.modules.Dialogue"
  • speech:LoadConversation("MyConv","FTSE.Dialogue.MyConv")
RunNode (conv, node, npc, plyr)
The RunNode function is used internally by FTSE to initiate transitions within the dialogue tree. It is not necessary to call this function directly to start a conversation; however, it can be useful within code-type nodes to move to a new node in the conversation.

Parameters:

  • conv The tag string for the conversation being processed.
  • node The name of the node to transition to.
  • npc The Entity corresponding to the NPC taking part in the conversation.
  • plyr The Entity corresponding to the player's squad member taking part in the conversation

Returns:

    Returns the Dialogue module object.

Helper functions for Choice conditions

skillcheck (skillparam, value)
skillcheck is a shortcut function for the condition field in Choice objects, returning true if the squad member meets the given skill check.

Parameters:

  • skillparam The name of the parameter as normally used in Actor:GetAttribute.
  • value The minimum value in the specified parameter.

Returns:

    A function object suitable for the condition field.
skillnotmet (skillparam, value)
skillnotmet is a shortcut function for the condition field in Choice objects, returning true if the squad member does not meet the given skill check.

Parameters:

  • skillparam The name of the parameter as normally used in Actor:GetAttribute.
  • value The value at which the choice will no longer be presented.

Returns:

    A function object suitable for the condition field.
campaignvar (var, value)
campaignvar is a shortcut function for the condition field in Choice objects, returning true if the listed campaign variable has the given value.

Parameters:

  • var The name of the campaign variable to check.
  • value The value at which the choice will be presented to the player.

Returns:

    A function object suitable for the condition field.
missionvar (var, value)
missionvar is a shortcut function for the condition field in Choice objects, returning true if the listed mission variable has the given value.

Parameters:

  • var The name of the mission variable to check.
  • value The value at which the choice will be presented to the player.

Returns:

    A function object suitable for the condition field.

Dialogue object fields

These fields are used in the C++-to-Lua linkage, and should generally not be modified by the script.
conversations
The conversations field is a table which includes all registered conversation objects.

Fields:

  • conversations
text
The text field is a string which indicates the NPC text to show in the FTSE Dialogue window.
  • text
audio
The audio field is a string which indicates which audio file should be played, if any.
  • audio
choices
The choices field is an array which contains Choice type objects, indicating which dialogue choices will be presented to the player.

Fields:

  • choices
choicestack
The choicestack field is an array which contains subtables of Choice objects, as a stack structure. This is used when nesting conversations.

Fields:

  • choicestack

Dialogue object types

These types describe the parameters which can be set in Node and Choice tables.
Node
The Node type defines each node in a conversation tree. A conversation tree object is a Lua table containing multiple Node objects, each with a key value indicating the node name.

Fields:

  • code For a code-type node, this field is required, and should be set to a Lua function, taking five arguments: Dialogue module handle, Converation name, Node name, NPC Entity, and Player Entity. This function will be called if/when the node is reached. For text-type nodes, this field should not be included.
  • text The text string to display in the NPC's conversation window when this node is reached. Required for text-type nodes.
  • audio The audio file to play when the node is reached. Optional.
  • clear If set to true, the list of player choices will be cleared prior to inserting any choices provided by this node. Optional.
  • pushstack If set to true, the current set of player choices will be saved in the choicestack, and a new empty table will be created for a nested conversation. This occurs prior to adding any choices provided by this node. Optional.
  • popstack If set to true, the current set of player choices will be discarded, and the most recently saved set of choices in choicestack will be restored (and removed from the stack). This occurs prior to adding any choices provided by this node. Optional.
  • choices An array of Choice tables which will be added to the set of converstaion options presented to the player. Note that only one active choice can point to any conversation node at a time; if a new choice is provided pointing to a node that is already in the list, the existing choice is replaced with the new one. Optional.
Choice
The Choice type defines a conversation choice which will be presented to the player.

Fields:

  • node The name of the node that this choice should transition to if selected. Required.
  • text The text that is shown as the player's words for this choice. The strings and , if placed in the string, will be substituted with the squad member's name or rank. Required unless the remove field is set.
  • priority The display priority for this choice. Lower-numbered choices will be displayed first. For example, it is common for the choice to leave a conversation to be the last one presented; setting the priority for that choice to the highest value will ensure that is the case. Required unless the remove field is set.
  • remove If set to true, the current choice leading to the specified node will be removed. Optional.
  • condition A function that will be called to determine if the choice should be presented to the player. This is typically used for skill-check choices, or choices which only occur if certain game state conditions apply. This should be set to a Lua function taking parameters: (Conversation Name, Node Name, NPC, Player), and returning true if the choice should be presented. There are shortcuts for common functions as described above.
generated by LDoc 1.4.6 Last updated 2026-03-26 23:57:00