Questions about Dialogue Editor

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jeuazarru
Posts: 10
Joined: Mon Jun 15, 2020 6:42 pm

Questions about Dialogue Editor

Post by jeuazarru »

Hi Tony, I am slowly moving my ink project to Dialogue System.

I did a first iteration of a dialogue to test most of my needs, but I am not sure if I am doing things as they should be, so I need some general advice, if you can help me.

First, in this example, I have a narrator, and one actor (the player) that acts and make decisions. So I created 2 actors, one for "the narrator" with isplayer unticked, and one actor "maincharacter" which is the player, with isplayer ticked. I wasn't sure if this is a good approach, or there is another way to have a narrator in the scene. I use the narrator for all the non interactive text, and the maincharacter to show the options to select an continue with the narrative.

All the previous issues with variables and C# functions and Lua are working now. But I am not sure if I am using the dialogue editor as it should be. I saw the videos and some examples but still not sure.

I attach an image, and ask some questions about.
Imagen1.jpg
Imagen1.jpg (180.61 KiB) Viewed 1179 times
My second question is... I have 3 options to start the dialogue, and then 18 different descriptions depending on a specific previous situations. So I created a grouping node marked as "group", pointed the 3 previous initial descriptions to it, and then this node points to the 18 descriptions. Each one has a state to check which one I should show. It works. But Not sure if this is the way to manage it, or of it may be better to have only one node instead of 18, as they are mutually exclusive, and in the text of the only node control the state variable and show the text depending on it. For sake of simplicity I should prefer the second option, instead of creating so many nodes.

Third question, after the 18 possibilities, I created a "gather node" to avoid having so many M to N relationships among the previos nodes and the next choices. Again, not sure if this is a good thing.

Fourth. I want a set of 4 choices to show. Only 1 of them gets you out, but the other 3 ones gives you more information, and then I need to show again the non visited ones. To do that I needed a new node below the previous gather node (I don't know the reason, but if i pointed the loop to the gather node it didn't worked), and then I created the 4 choices as the player, and when selected each choice goes to a child node with a description (by the narrator), and then those description nodes point to the original node, so the other options are shown again. I use state variables and simstatus to do that. Maybe there is another way to do the same? An option that I overlooked? so I can avoid doing the loop by hand?

Fifth, the previous loop worked, but it is strange, if I select the 3 previous options of the loop (not the exit one), in any order, i get an error on unity. The flow continues and I receive the last option anyways, but surely there is something wrong there. I understand it is something in the UI, but probably derived of an infinite loop or something like that? I am using the WRPG UI as it is, without changes. The error I see in the console is:
ArgumentException: Mesh can not have more than 65000 vertices
UnityEngine.UI.VertexHelper.FillMesh (UnityEngine.Mesh mesh)
UnityEngine.UI.Graphic.DoMeshGeneration ()
UnityEngine.UI.Graphic.UpdateGeometry ()
UnityEngine.UI.Text.UpdateGeometry ()
UnityEngine.UI.Graphic.Rebuild (UnityEngine.UI.CanvasUpdate update)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate ()
UnityEngine.Canvas:SendWillRenderCanvases()

And, final, 6th question in 2 parts, In the same previous 4 options, I want to show an option only if a specific of the other 3 had been shown, but not after it. I want to show 3 options at first, and if I pick the "analyze" option, then I replace that option with the new one. So I cannot put it below analyze because I want it to appear among the other 2 in replacement of the first one, and if I put it below, it sits alone without the other ones shown. Maybe, again, I am doing it wrong, so that's why asking for advice.
On the other side, to be able to do what I want, I check for SimStatus this way:
Dialog[thisID].SimStatus ~= "WasDisplayed" and Dialog[24].SimStatus == "WasDisplayed" (where 24 is the ID of the previous one). I don't like it, because I am afraid that if I add or remove nodes in the future, 24 might change to other number and then this control break? Or I can be sure that the ID will be 24 forever? Or there is another way to test by a name instead of the ID?

Sorry for the long email, but I believe if I get your advice on these questions, I will have covered most of my needs on the writing of the conversations and descriptions. Surely there is a long way to go, and some additional complexities, but at least I will be sure that I am doing things right.

Thanks a lot!
jeuazarru
Posts: 10
Joined: Mon Jun 15, 2020 6:42 pm

Re: Questions about Dialogue Editor

Post by jeuazarru »

And (sorry, one more question about actors and lua)

In one of the descriptions I take the maincharacter name from a c# script, and I show it in the text with this invocation: [lua(Nombre(Actor["MainCharacter"].Id))] where Id is a string identifier of the character that I created as a custom field in the database. "Nombre" is the name of the external function.

This perfectly works. But now I wanted to do a more general solution for dynamic conversations, and I saw this post: https://www.pixelcrushers.com/phpbb/vie ... f=3&t=3221

I want to use the current conversant and get the same value. In my example the actor is the narrator, and the conversant is the character I want to show the name.

I tried several things like [lua(Nombre(Actor[Variable["ConversantIndex"]].Id))] and it didn't work. I assumed that the actor is the narrator, so that is why it is not working. So i tried [lua(Nombre(Conversant[Variable["ConversantIndex"]].Id))] (maybe this doesn't even exits?)... I tried several syntax but none works. Probably I am doing it wrong, or I did not understood clearly how to access to conversand and actor data form within the text and use it in the external function call.

Any help will be appreciated
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions about Dialogue Editor

Post by Tony Li »

Hi,
jeuazarru wrote: Fri Jun 19, 2020 5:24 pm[About narrator as an actor]
But I am not sure if I am using the dialogue editor as it should be. I saw the videos and some examples but still not sure.
Yes, it's fine to use a separate actor for the narrator.
jeuazarru wrote: Fri Jun 19, 2020 5:24 pmMy second question is... I have 3 options to start the dialogue, and then 18 different descriptions depending on a specific previous situations....
It depends on the conditions on those nodes. Here are two ideas to simplify it:

1. Before the conversation starts, set a Lua variable. Example:

Code: Select all

DialogueLua.SetVariable("RequiredAge", 18)
and then check that value in a single node instead of 18 nodes:

jeuazarru_2a.png
jeuazarru_2a.png (18.86 KiB) Viewed 1175 times

2. Or write a C# method to do the check(s):

jeuazarru_2b.png
jeuazarru_2b.png (17.55 KiB) Viewed 1175 times
jeuazarru wrote: Fri Jun 19, 2020 5:24 pmThird question, after the 18 possibilities, I created a "gather node" to avoid having so many M to N relationships among the previos nodes and the next choices. Again, not sure if this is a good thing.
Yes, it's certainly better to collect them into one "gather" node than use M-to-N links.
jeuazarru wrote: Fri Jun 19, 2020 5:24 pmFourth. I want a set of 4 choices to show. Only 1 of them gets you out, but the other 3 ones gives you more information, and then I need to show again the non visited ones. To do that I needed a new node below the previous gather node (I don't know the reason, but if i pointed the loop to the gather node it didn't worked)
This is probably because Conversations Evaluate Conditions One Extra Level Ahead. Since group nodes are passthroughs, they don't count as a level by themselves.

Another way to avoid a loop is to use Conversation Position Stack functions. These functions let you push the current conversation position onto a stack and later pop it off the stack to return to that position.
jeuazarru wrote: Fri Jun 19, 2020 5:24 pmFifth, the previous loop worked, but it is strange, if I select the 3 previous options of the loop (not the exit one), in any order, i get an error on unity.
Yes, you probably created an infinite loop that kept adding text until it overflowed.
jeuazarru wrote: Fri Jun 19, 2020 5:24 pmAnd, final, 6th question in 2 parts, In the same previous 4 options, I want to show an option only if a specific of the other 3 had been shown, but not after it
As long as you don't delete and recreate the dialogue entry that has ID 24, it will have ID 24 forever. SimStatus always works by ID, not by name.

If you don't want to use SimStatus, you can use variables. When the player chooses the first (prerequisite) option, set the variable true. On the second option, set the Conditions to require that the variable is true.
jeuazarru wrote: Fri Jun 19, 2020 6:04 pmI tried several things like [lua(Nombre(Actor[Variable["ConversantIndex"]].Id))] and it didn't work. I assumed that the actor is the narrator, so that is why it is not working.
That looks like it should work.

Try check the value in a Lua Console or the Dialogue Editor's Watches section.

Break it down. First check that Variable["ConversantIndex"] returns the correct value. Then check if Actor[Variable["ConversantIndex"]].Id returns the correct value.
jeuazarru
Posts: 10
Joined: Mon Jun 15, 2020 6:42 pm

Re: Questions about Dialogue Editor

Post by jeuazarru »

Thank you Tony. About the 18 nodes... I currently are using a variable to test against. I wanted to know if instead of having 18 nodes (each one has a different text), with each one having a condition on the content of the variable, I can have only one node, without conditions, and in the text area have a switch case based on the variable, showing only the specific text for that state.
I do that easily in Ink, and wanted to know how to show conditional text using lua inside the text field. If you can give me an example it will be awesome!
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions about Dialogue Editor

Post by Tony Li »

Got it. You could write a C# method that takes two parameters: a variable name and a string containing text broken up by '|' characters. Example:

Code: Select all

string VariableText(string variableName, string allText)
{
    string[] texts = allText.Split('|');
    int variableValue = DialogueLua.GetVariable("variableName").asInt;
    return texts[variableValue];
}
To call it in C#, you'd use it like this:

Code: Select all

DialogueLua.SetVariable("x", 1);
Debug.Log( VariableText("x", "First|Second|Third") );
This will log "Second".

Note: To keep the code example readable, it doesn't do any bounds checking. Your code should do bounds checking.

Then register this as a Lua function. Then you can set the Dialogue Text to something like:
  • Dialogue Text: "Let me tell you about [lua( VariableText("x", "First|Second|Third") )].
jeuazarru
Posts: 10
Joined: Mon Jun 15, 2020 6:42 pm

Re: Questions about Dialogue Editor

Post by jeuazarru »

Thank you Tony.

I prefer to have all the text on the Dialogue DB, that's why I was asking about a switch case in text. No worries, I will find out the best option. I solved the previous question about conversantindex also. Regards!
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Questions about Dialogue Editor

Post by Tony Li »

While that does keep all the text in the DB, on second thought it would be better to process it in an OnConversationLine method. For example, you could write your Dialogue Text like this:
  • Dialogue Text: "x|First|Second|Third"
Then add a script with a method like this to the Dialogue Manager:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.formattedText.text.Contains("|"))
    {
        string[] texts = subtitle.formattedText.text.Split('|');
        string varName = texts[0];
        int varValue = DialogueLua.GetVariable(varValue).asInt;
        subtitle.formattedText.text = texts[varValue];
    }    
}
That method counts from 1. So if you set the variable "x" to 2, the conversation will show "Second".
jeuazarru
Posts: 10
Joined: Mon Jun 15, 2020 6:42 pm

Re: Questions about Dialogue Editor

Post by jeuazarru »

Thanks a lot!
Post Reply