Conversations

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Argaen
Posts: 4
Joined: Thu Sep 04, 2014 11:26 pm

Conversations

Post by Argaen »

Hey guys,



I've been through the docs and I can't seem to find the answer. Is there a way to test if a Conversation exists before trying to call it?



The latest thing I've tried is:



bool exists = DialogueLua.DoesTableElementExist("Conversation", barkName);



Which seems like it should work but always returns false.







Any ideas?
Argaen
Posts: 4
Joined: Thu Sep 04, 2014 11:26 pm

Conversations

Post by Argaen »

So poking around some more, this seems to work:







public static bool ConversationExists(string title)



{



List<Conversation> convs = DialogueManager.DatabaseManager.MasterDatabase.conversations;







foreach (Conversation c in convs)



{



if (c.Title == title)



return true;



}







return false;



}







Is there a better way to do it?
User avatar
Tony Li
Posts: 21675
Joined: Thu Jul 18, 2013 1:27 pm

Conversations

Post by Tony Li »

Try this:



bool exists = (DialogueManager.MasterDatabase.GetConversation(title) != null);



It does the same thing, but it's shorter.



Then, to make sure the conversation has a valid dialogue entry for the current state of the game, you can check:



bool hasAnEntry = DialogueManager.ConversationHasValidEntry(title);



This function also accepts an actor and conversant in case the dialogue entries' Conditions depend on values on the actor and conversant.



Here's the Dialogue Manager class reference.
Post Reply