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?
Conversations
Conversations
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?
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?
Conversations
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.
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.