Adding external conversations through code adds empty response button in between
Posted: Thu Jun 23, 2016 4:10 am
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:
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:
This code is being called with this line:
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:
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
So, let's start with a screenshot:
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));
}
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
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