Tracking the progression inside a conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ProvencalG
Posts: 24
Joined: Fri Mar 13, 2020 1:30 pm

Tracking the progression inside a conversation

Post by ProvencalG »

Hi.

Is there a way to find out how many dialogue entries has been played? Or how many choices the player made?

I need to find a way to track the current conversation progress (but I don't really care about which dialogue node he is on, just how much he went through).
So I guess I could just make a script that increment a value each time the player answers an reset it to 0 at Conversation start. Put it on the Dialogue Manager. OnConversationStart looks like the right event for the reset, but I did not find an event for when the player answers.

Is there a easy way to implement this?
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tracking the progression inside a conversation

Post by Tony Li »

Hi,

Assign methods to a Dialogue System Events component's OnConversation and OnConversationLine, or add the same as script methods:

Code: Select all

int numResponses;

void OnConversationStart(Transform actor)
{
    numResponses = 0;
}

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.speakerInfo.isPlayer) numResponses++;
}
ProvencalG
Posts: 24
Joined: Fri Mar 13, 2020 1:30 pm

Re: Tracking the progression inside a conversation

Post by ProvencalG »

Thanks. Of course I did not think about simply checking if the speaker was the player.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tracking the progression inside a conversation

Post by Tony Li »

Happy to help!
ProvencalG
Posts: 24
Joined: Fri Mar 13, 2020 1:30 pm

Re: Tracking the progression inside a conversation

Post by ProvencalG »

I have another question.
I have a boolean on my all my conversations and want to set them in dialogue entries.
The Script field was looking perfect for that but I can't access conversation's variables in it. By that I mean the new custom boolean field I added to every conversations using Template.
So, I could put those booleans on actors, or create a bunch of variables (one for each conversations). But that don't seem to make sense for me.

Is there something I am missing?
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tracking the progression inside a conversation

Post by Tony Li »

Hi,

There's isn't a "..." dropdown shortcut, but you can add the Lua expression manually to Conditions and Scripts. The other catch is that they are organized by conversation ID number. So a Script field might look like this:

Code: Select all

Conversation[42].MyCustomBoolean = true
That isn't very readable. I recommend variables for this. Take the Dialogue System's demo for example. It has three conversations: "Private Hart", "Sergeant Graves", and "Terminal". Say you want to add a Boolean to record if the conversation was played. You could name the variables:
  • Played.PrivateHart
  • Played.SergeantGraves
  • Played.Terminal
Then you can sort the variables list to group all of the "Played.*" variables together. Or set the filter to "Played." to see only these variables.

Your Script fields could look like this, which is easier to understand than conversation IDs:

Code: Select all

Variable["Played.PrivateHart"] = true
And you can use the "..." dropdowns, so you don't have to type anything.
ProvencalG
Posts: 24
Joined: Fri Mar 13, 2020 1:30 pm

Re: Tracking the progression inside a conversation

Post by ProvencalG »

Thanks.
Yes, writing "Conversation[42].MyCustomBoolean = true" in the script fields is not really readable.

So I get that setting a variable, with good naming structure is better.
But in a script I want to access that boolean and check it in any conversation context.

That means that for example if I had a "MyCustomBoolean" on every conversation I could check it on the conversation being played. But "Played.SergeantGraves.1" is specific to one conversation and that would mean that I would have to check the name of the conversation "SergeantGraves/1", translate this into the variable naming structure.

Code: Select all

string convName.Replace("/", "."); 
But how do I access the current variable value?

Code: Select all

bool played = DialogueManager.masterDatabase.GetVariable("Played." + convName).InitialValue;
this gives only the initial value obviously, so it's not really useful.

So how do I access it?? I don't know. I'm quite lost here.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tracking the progression inside a conversation

Post by Tony Li »

Hi,

Use the DialogueLua class. Dialogue databases are static at runtime. All changes go into Lua. BTW, I think you can use the same variable names as your conversation titles (e.g., "SergeantGraves/1").

Code: Select all

bool played = DialogueLua.GetVariable("Played." + convName).asBool;
ProvencalG
Posts: 24
Joined: Fri Mar 13, 2020 1:30 pm

Re: Tracking the progression inside a conversation

Post by ProvencalG »

Oh I see I totally missed this info. Thanks a lot! Very quick answer by the way, that's great!
Last edited by ProvencalG on Tue May 05, 2020 3:46 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tracking the progression inside a conversation

Post by Tony Li »

Glad to help! :-)
Post Reply