Page 1 of 1

Conditional Dialogue Flow Between Child Nodes

Posted: Thu Sep 07, 2023 6:16 pm
by elektronische
Hello!

I'm working on a new feature and have come across a scenario I'm unsure about.

I have a parent node, let's call it Node A, which has two child nodes: Node B and Node C. My objective is to set up the system in such a way that after Node A's dialogue is displayed, the system would transition to Node B if a certain condition is met. However, if that condition isn't met, it should proceed with Node C's dialogue.

Is there a way to implement this conditional transition between the child nodes based on the state of the specified condition?

Thank you in advance for any guidance!

Re: Conditional Dialogue Flow Between Child Nodes

Posted: Thu Sep 07, 2023 7:39 pm
by Tony Li
Yes, absolutely. Please see Conversation Conditions Tutorial.

You can also use your own C# methods in Conditions by registering the methods with Lua.

See also: Conversations Evaluate Conditions One Extra Level Ahead

Re: Conditional Dialogue Flow Between Child Nodes

Posted: Tue Sep 12, 2023 3:20 pm
by elektronische
Thank you so much for the response! I have already achieved the functionality I wanted.

Now I have a new question regarding a different topic, but it eventually relates to my project. It's about the process of localizing variables, for instance, if I have a variable that I want to display inside a node, which I set from the code, like this:

Code: Select all

DialogueLua.SetVariable("Choice1", "Text Choice 1");
And then I display it in a node like this:

[var=Choice1]

I need to modify that Choice1 value in runtime not only for the "Dialogue Text" but also for each localization language. Do you know if there's any efficient way to do this?

Thank you.

Re: Conditional Dialogue Flow Between Child Nodes

Posted: Tue Sep 12, 2023 5:07 pm
by Tony Li
Hi,

Dialogue databases have their own localization.

However, if you want to set the variable value from another source using C#, you can use a text table. For example, say your text table has a field named "Dance" with English(en/default) = "dance" and German(de) = "tanzen".

Then assign the text table to the Dialogue Manager's Localization Setting section, and use DialogueManager.GetLocalizedText:

Code: Select all

DialogueLua.SetVariable("Choice1", DialogueManager.GetLocalizedText("Dance"));