Difference between revisions of "LUA:AddConversationOption"
(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]) ===...") |
|||
| Line 1: | Line 1: | ||
| − | = | + | {{LUAFunction |
| − | Adds an option for a player to select in a dialog with an NPC. | + | |Name = AddConversationOption |
| − | + | |Description = Adds an option for a player to select in a dialog with an NPC. | |
| − | + | |Param1 = conversation | |
| − | = | + | |Param1Desc = must be a conversation |
| − | + | |Param2 = string | |
| − | + | |Param2Desc = is the option to add to the given conversation | |
| − | + | |OptionalParam1 = string | |
| − | + | |OptionalParam1Desc = is the custom function to call if this option is selected | |
| − | + | |Example = | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
<pre> | <pre> | ||
| − | + | function hailed(NPC, Spawn) | |
-- have the NPC face the player | -- have the NPC face the player | ||
FaceTarget(NPC, Spawn) | FaceTarget(NPC, Spawn) | ||
| Line 31: | Line 23: | ||
end | end | ||
</pre> | </pre> | ||
| − | + | |ExampleDesc = This script makes a conversation with 3 choices for the player. | |
| − | 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. |
| − | + | }} | |
| − | |||
| − | |||
| − | If '' | ||
Latest revision as of 13:25, 27 January 2021
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.