Marking Dialogue Nodes as visited

Announcements, support questions, and discussion for the Dialogue System.
Itilos
Posts: 21
Joined: Thu Oct 20, 2022 12:03 am

Marking Dialogue Nodes as visited

Post by Itilos »

Hello!

Is there any way to mark a specific dialogue node as visited? I have an information-gathering group of nodes, and I want to change the color of text of dialogue options we have already visited so that it's clear to the player.

I'm using a Response Button Template to generate the dialogue buttons - trying to figure out if there's a built-in way to pass a "visited" variable from the dialogue node specified to the button itself.
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Marking Dialogue Nodes as visited

Post by Tony Li »

Hi,

You can either define a Dialogue System variable (e.g., in the Dialogue Editor's Variables section) and set it in the node's Script field, or you can use the built-in SimStatus feature.
Itilos
Posts: 21
Joined: Thu Oct 20, 2022 12:03 am

Re: Marking Dialogue Nodes as visited

Post by Itilos »

This is very helpful! A few more questions then:

Defining a variable in the variables section seems impossible for this use-case, correct? If each node needs to know whether or not it is visited, I would have to declare a global variable per each node, it seems. Let me know if I am misunderstanding.

As far as SimStatus goes - this looks like exactly what I need. However, how does one access the Dialogue[ID].SimStatus value from C#? It's not entirely clear to me how the Lua and C# code interact.
Itilos
Posts: 21
Joined: Thu Oct 20, 2022 12:03 am

Re: Marking Dialogue Nodes as visited

Post by Itilos »

I will add - I did watch this:


It seems to show how to access C# variables from Lua scripts, but not how to access SimStatus/Lua variables from C# code.
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Marking Dialogue Nodes as visited

Post by Tony Li »

Hi,

If you use SimStatus, you'll use this form in Lua -- typically, in a dialogue entry node's Conditions field. To check the visited status of the current node:

Code: Select all

Dialog[thisID].SimStatus == "WasDisplayed"
To check the status of some other node with ID 42 in the conversation:

Code: Select all

Dialog[42].SimStatus == "WasDisplayed"
To check in C#, use DialogueLua.GetSimStatus():

Code: Select all

var currentEntry = DialogueManager.masterDatabase.GetDialogueEntry(link);
if (DialogueLua.GetSimStatus(currentEntry) == DialogueLua.WasDisplayed)
{ ... }
If you want to get and set variables in C#, use DialogueLua.GetVariable() and DialogueLua.SetVariable().
Itilos
Posts: 21
Joined: Thu Oct 20, 2022 12:03 am

Re: Marking Dialogue Nodes as visited

Post by Itilos »

That makes sense!

One last thing in this chain of logic - how would a ResponseButton initialized by a ResponseButtonTemplate know the ID/which DialogueEntry it is associated with?

I looked through the docs and it seems like you could do

Code: Select all

DialogueManager.instance.currentConversationState.pcResponses.formattedText 
and compare it with the button's text.

String comparison like this seems non-ideal, however. Is there an easier way to get the current nodes from the buttons rendered?
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Marking Dialogue Nodes as visited

Post by Tony Li »

Hi,

Response buttons will have StandardUIResponseButton components. This component has a response property. The response property has a destinationEntry, which is the dialogue entry to show if the player chooses the response. The destinationEntry has an id, which is the ID of the dialogue entry. So you can check:

Code: Select all

DialogueEntry entry = GetComponent<StandardUIResponseButton>().response.destinationEntry;
string simStatus = DialogueLua.GetSimStatus(entry);
But, stepping back a bit, what do you want to accomplish? There might be a more straightforward, built-in way to do it.
Itilos
Posts: 21
Joined: Thu Oct 20, 2022 12:03 am

Re: Marking Dialogue Nodes as visited

Post by Itilos »

That makes sense! That will probably work.

The goal of this is two-fold:

A: Change the color of dialogue options that have already been selected (in info-gathering situations).
B: Perhaps use this to number dialogue options (ie 1, 2, 3, 4)

Do you see a more straightforward way to do this?
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Marking Dialogue Nodes as visited

Post by Tony Li »

Hi,

> A: Change the color of dialogue options that have already been selected (in info-gathering situations).

You could set the Dialogue Manager GameObject's Display Settings > Input Settings > [em#] Tag for Old Responses.


> B: Perhaps use this to number dialogue options (ie 1, 2, 3, 4)

If you mean just putting numbers in front of responses (and assigning number key hotkeys), inspect the response menu panel and tick the Standard UI Menu Panel component's Autonumber > Enabled checkbox.

If you mean reordering the responses -- for example to put already-selected responses at the bottom -- you can do this using DialogueLua.GetSimStatus() in an OnConversationResponseMenu(Response[]) method.
Itilos
Posts: 21
Joined: Thu Oct 20, 2022 12:03 am

Re: Marking Dialogue Nodes as visited

Post by Itilos »

Great! Autonumber works well.

For the "[em#] Tag for Old Responses" - I enabled this, but nothing seems to happen. Do I need to define what "Em 1" is somewhere, so that I can set the color?
Post Reply