Adding external conversations through code adds empty response button in between

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Ders
Posts: 18
Joined: Thu Mar 10, 2016 3:53 am

Adding external conversations through code adds empty response button in between

Post by Ders »

I have made a system that adds an external conversation "link" through code when we want it, so at runtime. For some reason I have the following problem: there is an empty response button I need to press before it actually goes in to that external conversation, and obviously, I want to get rid of that.
So, let's start with a screenshot:

Image

You can see the TestConversation node that I selected, which is one that is added to this conversation at runtime. As you can see to the right, it links to the ExternalConversation called "TestConversation". and the destinationDialogueID is set to 0 for that conversation. I would assume that, when I press the TestConversation response button in my game it would just start the external conversation, but for some reason it adds an empty response button in between that I have to select before it actually starts the external conversation.
Here's the code I'm using to add this node with the external conversation link to the original conversation:

Code: Select all

public static void AddNewExternalConversation(ref Conversation conversation, string externalConversationTitle, int previousNode, bool isPlayerChoice, string dialogueText, string condition, string script) {
        var nodes = conversation.dialogueEntries;
        Conversation externalConversation = DialogueManager.DatabaseManager.DefaultDatabase.conversations.Find(x => x.Title == externalConversationTitle);

        var id = 1 + conversation.dialogueEntries.Max(existingEntry => existingEntry.id);
        DialogueEntry newEntry = template.CreateDialogueEntry(id, conversation.id, "My Title");
        newEntry.conversationID = conversation.id;
        newEntry.Title = "Empty";
        newEntry.DialogueText = dialogueText;
        newEntry.conditionsString = condition;
        newEntry.userScript = script;
        newEntry.ActorID = isPlayerChoice ? 1 : 2;
        newEntry.ConversantID = isPlayerChoice ? 2 : 1;
        nodes.Add(newEntry);

	nodes.Find(x => x.id == newEntry.id).outgoingLinks.Add(new Link(conversation.id, newEntry.id, externalConversation.id, 0));
        nodes[previousNode].outgoingLinks.Add(new Link(conversation.id, previousNode, conversation.id, newEntry.id));
    }
This code is being called with this line:

Code: Select all

ConversationCreator.AddNewExternalConversation(ref extendableConversation, externalConversationTitle, 0, true, dialogueText, "", "");
// arguments: original conversation, external conversation title, previous node, is player choice, dialogue text, condition text, script text
I'm not really sure what's going on. I added the external conversation manually as well, and then it doesn't even show anything, it just exits. The external conversation looks like this:

Image

so there's nothing special that I can see. Nothing seems wrong either. I selected the first node because it has a simple condition in it, but that's it. I did this condition because I noticed setting the destinationDialogueID to 1 but this would only work if it actually needs to show the node with id 1. So in this case I was trying to see if it worked, and it doesn't. It skips the conversation completely. All the other things I talked about here were with this destinationDialogueID set to 0 like it should be though.

I hope this is clear, and someone can help me with this. If needed, I can show more code
User avatar
Tony Li
Posts: 20764
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adding external conversations through code adds empty response button in between

Post by Tony Li »

Hi,

Cross-conversation links cannot link to another conversation's START node (i.e., dialogue entry ID 0). This is a restriction of the Chat Mapper data format. Can you create a node (let's call it "External_Entry_Point") in the TestConversation and link to that node? If you set External_Entry_Point's isGroup bool to true, the Dialogue System will pass through the node without presenting it as a response button.
Ders
Posts: 18
Joined: Thu Mar 10, 2016 3:53 am

Re: Adding external conversations through code adds empty response button in between

Post by Ders »

That is indeed the solution! I tried it out with the Start button as well (setting the isGroup bool to true) and that seems to work as well (we're not using ChatMapper so I guess this is fine).

Thanks :)
User avatar
Tony Li
Posts: 20764
Joined: Thu Jul 18, 2013 1:27 pm

Re: Adding external conversations through code adds empty response button in between

Post by Tony Li »

Happy to help. Glad it's working!
Post Reply