Hi,
I was wondering if there was any way to use the StartConversation method to call a specific line using the Title of the dialogue entry instead of its ID.
I asked because we have a system of Tips that the player can activate when fighting different monsters and it would be a lot easier if we could call the conversation by using the title of the dialogue (which would be the name of the monster they are facing) instead of a number.
Something like StartConversation("Tips",Actor,Conversant,MonsterName);
Thanks.
Starting a conversation with the Dialogue Entry Title instead of ID?
-
- Posts: 20
- Joined: Sun Apr 04, 2021 11:54 am
Re: Starting a conversation with the Dialogue Entry Title instead of ID?
Hi,
If you're talking about the DialogueManager.StartConversation() C# method, it already works by title.
Dialogue System Triggers also work by title.
What method are you currently using to start a conversation by ID?
If you're talking about the DialogueManager.StartConversation() C# method, it already works by title.
Dialogue System Triggers also work by title.
What method are you currently using to start a conversation by ID?
-
- Posts: 20
- Joined: Sun Apr 04, 2021 11:54 am
Re: Starting a conversation with the Dialogue Entry Title instead of ID?
Well, I have a Conversation with the title "Tips" and inside of it a Dialogue Entry with the title "Scrat" (and the Node ID# 1), which is the name of one of our monsters.
Now, when I'm fighting a Scrat and click on the Tip button, I currently trigger the following through C# script :
StartConversation("Tips",Actor,Conversant,1);
And that works fine.
But, what I would like to be able to do is call that specific Dialogue Entry from it's title instead of its ID number.
I can call the whole Conversation with its title with StartConversation("Tips"), but that will only start at the Start Node.
I would like to be able to call the dialogue entry directly using its title with something like StartConversation("Scrat"), or StartConversation("Tips",Actor,Conversant,"Scrat");
That would required another type of StartConversation with something like:
StartConversation(string conversationTitle, Transform actor, Transform conversant, string initialDialogueEntryTitle) instead of
StartConversation(string title, Transform actor, Transform conversant, int initialDialogueEntryID)
Is there any way to do this currently? Or an easy way to make it happen through script?
Now, when I'm fighting a Scrat and click on the Tip button, I currently trigger the following through C# script :
StartConversation("Tips",Actor,Conversant,1);
And that works fine.
But, what I would like to be able to do is call that specific Dialogue Entry from it's title instead of its ID number.
I can call the whole Conversation with its title with StartConversation("Tips"), but that will only start at the Start Node.
I would like to be able to call the dialogue entry directly using its title with something like StartConversation("Scrat"), or StartConversation("Tips",Actor,Conversant,"Scrat");
That would required another type of StartConversation with something like:
StartConversation(string conversationTitle, Transform actor, Transform conversant, string initialDialogueEntryTitle) instead of
StartConversation(string title, Transform actor, Transform conversant, int initialDialogueEntryID)
Is there any way to do this currently? Or an easy way to make it happen through script?
Re: Starting a conversation with the Dialogue Entry Title instead of ID?
Sorry, I misread your original question.
You can write a function to get a dialogue entry ID from its title, or combine it with a wrapper method for DialogueManager.StartConversation like this:
Then use it like this:
You can write a function to get a dialogue entry ID from its title, or combine it with a wrapper method for DialogueManager.StartConversation like this:
Code: Select all
public void StartConversationByEntryTitle(string conversationTitle, string entryTitle, Transform actor, Transform conversant)
{
var conversation = DialogueManager.masterDatabase.GetConversation(conversationTitle);
if (conversation == null)
{
Debug.LogWarning($"No conversation '{conversationTitle}'");
}
else
{
var entry = conversation.GetDialogueEntry(entryTitle);
if (entry == null)
{
Debug.LogWarning($"No entry titled '{entryTitle}' in conversation '{conversationTitle}'");
}
else
{
DialogueManager.StartConversation(conversationTitle, actor, transform, entry.id);
}
}
}
Code: Select all
StartConversationByEntryTitle("Tips", "Scrat", Actor, Conversant);
-
- Posts: 20
- Joined: Sun Apr 04, 2021 11:54 am
Re: Starting a conversation with the Dialogue Entry Title instead of ID?
That worked perfectly! Thanks!
PS: I also learned about Interpolated Strings thanks to your reply! Very useful!
PS: I also learned about Interpolated Strings thanks to your reply! Very useful!