Index
Page Contents

NPC Conversastion Lua Functions

These functions are available to Lua scripts executed within an NPC Conversation Script.


These functions are available to Lua scripts executed within an NPC Conversation Script. They cannot be used outside of an NPC conversation.

Global Variables

LUA scripts run from within an NPC conversation have access to the following additional global variables in Lua:

  • pc_id - ID of player character in the conversation
  • npc_id - ID of the NPC the player initiated the conversation with. (Beware of this in multi-character conversations!)

Conversation Functions

SetCurrentConversationNode

SetCurrentConversationNode(player_instance_id, node_id)

Parameters

  • playerinstanceid - The player character instance id (typically pc_id)
  • node_id - The conversation node that the conversation should continue from.

Example

SetCurrentConversationNode( pc_id, "my-node" )

GetCurrentConversationNode

SetCurrentConversationNode(player_instance_id, node_id)

Parameters

  • playerinstanceid - The player character instance id (typically pc_id)

Example

local node_id = GetCurrentConversationNode( pc_id )

Information

Get the current conversation node id.

SetTag

SetTag(player_instance_id, tag_name, tag_replace)

Parameters

  • playerinstanceid - The player character instance id (typically pc_id)
  • tag_name - The tag to replace in the character's current conversation node.
  • tag_replace - The value the tag will be replaced with

Example NPC Conversation Node

.start-familiar run: local name = GetPCValue( pc_id, "character.name" ) run: SetTag( pc_id, "pc_char_name", name ) say: Welcome Back, [[pc_char_name]].

Information

NPC Character Conversations can have tags in them that get replaced with values via LUA before the node is displayed to the player. Use this function to set the tag replacement value before presenting the text to the player.

GetTag

GetTag(player_instance_id, tag_name)

Parameters

  • playerinstanceid - The player character instance id (typically pc_id)
  • tag_name - The tag to replace in the character's current conversation node.

Example NPC Conversation Node

local val = GetTag( pc_id, "pc_char_name" )

Information

NPC Character Conversations can have tags in them that get replaced with values via LUA before the node is displayed to the player. This function can retrieve the value that will be displayed for a tag. (It is rare that you would need to use this function.)

Conversation Variables

SetNPCVariable

GetNPCVariable

SetConversationVar

GetConversationVar

Quest Functions

HasQuest

IsQuestParticipant

GetQuestParticipantRole

GetQuestObjectiveCompleted

GetQuestChapter

InConversationRange

Player Character Access Functions

Note:These functions access a clone of the player character that was taken when the conversation was initiated. They can fall out-of-date over time if the conversation persists for a long time. (I may eventually add a 'UpdatePCCache' function that can be called before critical logic is performed.)

GetPCValue

GetPCStatisticValue