Difference between revisions of "Dialog System"

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search
Line 1: Line 1:
This is a Stub page.
+
The Dialog system is easy to use once you get use to how it is structured. You can find all the basic functions to override within the base_ai_npc.lua file. When you open this file you will notice the Dialog variable. This table holds all the dialog related functions. Lets discuss the life time of the dialog window shall we. When the player interacts with the npc, an event messaged named "base_ai_conversation" fires up the HandleInteract function. At the botton of this function for basic dialog interact Dialog.OpenGreetingDialog(user) is called. This opens up the dialog.
<br>Since many of us admins basically have no clue how to use and create new dialogs for NPCs, could someone from CS jump in and give us at least a primer here?
 
  
The Dialog system is easy to use once you get use to how it is structured. You can find all the basic functions to override within the base_ai_npc.lua file. When you open this file you will notice the Dialog variable. This table holds all the dialog related functions.
 
  
Lets discuss the life time of the dialog window shall we. When the player interacts with the npc, an event messaged named "base_ai_conversation" fires up the HandleInteract function. At the botton of this function for basic dialog interact Dialog.OpenGreetingDialog(user) is called. This opens up the dialog.
+
Here is an example of a simple Greetings Dialog override.
 +
<syntaxhighlight lang="lua">
 +
function Dialog.OpenGreetingDialog(user)
 +
    -- this is the npcs dialog text for this conversation
 +
    text = "Hello Stranger, What brings you to my part of town?"
 +
   
 +
    -- a table containing player response information
 +
    response = {}
 +
    response[1] = {}
 +
    response[1].text = "Do you know the muffin Man?"
 +
    response[1].handle = "MuffinMan"
 +
 
 +
    -- this displays the dialog information to the user
 +
    NPCInteractionLongButton(text,this,user,"Responses",response)
 +
end
 +
</syntaxhighlight>
 +
 
 +
Now we need to create the next part of the dailog which is another function. These functions for each new dialog are in the following format. Lets see what it looks like and then we will make the function for when the player clicks the MuffinMan response.
 +
 
 +
Here is the function Format for dialog responses below
 +
function Dialog.Open[RESPONSE_HANDLE]Dialog(user)  
  
Here is an example of a simple Greetings Dialog override.
+
Here is an example function for the MuffinMan response.
 +
<syntaxhighlight lang="lua">
 +
function OpenMuffinManDialog(user)
 +
    -- this is the npcs dialog text for this conversation
 +
    text = "Oh the muffin man, he is a strange person I tell ya, but thats all I know"
 +
   
 +
    -- a table containing player response information
 +
    response = {}
 +
    response[1] = {}
 +
    response[1].text = "Very Interesting?"
 +
    response[1].handle = "Greetings"
 +
 
 +
    -- this displays the dialog information to the user
 +
    NPCInteractionLongButton(text,this,user,"Responses",response)
 +
end
 +
</syntaxhighlight>
  
function Dialog.OpenGreetingDialog(user)
+
This open muffinman dialog function will send the player back to the "Greetings" dialog. The response[?].handle is the name of the dialog, so in this second function we are sending the player back to the greeting.
    text = "Hello Stranger, What brings you to my part of town?"
 
    response = {}
 
    response[1] = {}
 
    response[1].text = "Do you know the muffin Man?"
 
    response[1].handle = "MuffinMan"   
 
 
    NPCInteractionLongButton(text,this,user,"Responses",response)
 
end
 
 
[[Category:Systems]]
 
[[Category:Systems]]

Revision as of 17:11, 26 May 2021

The Dialog system is easy to use once you get use to how it is structured. You can find all the basic functions to override within the base_ai_npc.lua file. When you open this file you will notice the Dialog variable. This table holds all the dialog related functions. Lets discuss the life time of the dialog window shall we. When the player interacts with the npc, an event messaged named "base_ai_conversation" fires up the HandleInteract function. At the botton of this function for basic dialog interact Dialog.OpenGreetingDialog(user) is called. This opens up the dialog.


Here is an example of a simple Greetings Dialog override.

function Dialog.OpenGreetingDialog(user)
    -- this is the npcs dialog text for this conversation 
    text = "Hello Stranger, What brings you to my part of town?"
    
    -- a table containing player response information
    response = {}
    response[1] = {}
    response[1].text = "Do you know the muffin Man?"
    response[1].handle = "MuffinMan"

    -- this displays the dialog information to the user
    NPCInteractionLongButton(text,this,user,"Responses",response)
end

Now we need to create the next part of the dailog which is another function. These functions for each new dialog are in the following format. Lets see what it looks like and then we will make the function for when the player clicks the MuffinMan response.

Here is the function Format for dialog responses below

function Dialog.Open[RESPONSE_HANDLE]Dialog(user) 

Here is an example function for the MuffinMan response.

function OpenMuffinManDialog(user)
    -- this is the npcs dialog text for this conversation 
    text = "Oh the muffin man, he is a strange person I tell ya, but thats all I know"
    
    -- a table containing player response information
    response = {}
    response[1] = {}
    response[1].text = "Very Interesting?"
    response[1].handle = "Greetings"

    -- this displays the dialog information to the user
    NPCInteractionLongButton(text,this,user,"Responses",response) 
end

This open muffinman dialog function will send the player back to the "Greetings" dialog. The response[?].handle is the name of the dialog, so in this second function we are sending the player back to the greeting.