No categories assigned

LUA:AddConversationOption


LUA:AllFunctions - AddConversationOption

Return to: LUA:AllFunctions | Tutorials | Portal | Forum | Project Manager | Bug Tracker


Adds an option for a player to select in a dialog with an NPC.

Syntax

AddConversationOption(param1, param2, [opt param1])

Parameters

Required - param1 (conversation), param2 (string)
param1 must be a conversation
param2 is the option to add to the given conversation
Optional - opt param1 (string)
opt param1 is the custom function to call if this option is selected

Example

function hailed(NPC, Spawn)
	-- have the NPC face the player
        FaceTarget(NPC, Spawn)
	-- create the conversation
	conversation = CreateConversation()
	-- set the 3 player options
	AddConversationOption(conversation, "Good", "Choice1")
	AddConversationOption(conversation, "Not so good.", "Choice2")
	AddConversationOption(conversation, "I don't have time for this.")
	-- set the npc dialog and start the conversation
	StartConversation(conversation, NPC, Spawn, "Good to see you " .. GetName(Spawn) .. ", how are you today?")
 end

This script makes a conversation with 3 choices for the player.

Notes

If opt param1 is left out then when the player selects that option the dialog will close.