No categories assigned

LUA:AddConversationOption

Revision as of 21:07, 10 October 2012 by Jabantiz (talk | contribs) (Created page with "= LUA Functions: AddConversationOption() = Adds an option for a player to select in a dialog with an NPC. ==== Syntax ==== AddConversationOption(param1, param2, [param3]) ===...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

LUA Functions: AddConversationOption()

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


Syntax

AddConversationOption(param1, param2, [param3])


Parameters

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


Usage

 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 param3 is left out then when the player selects that option the dialog will close.