Tracking the progression inside a conversation
-
- Posts: 24
- Joined: Fri Mar 13, 2020 1:30 pm
Tracking the progression inside a conversation
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?
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?
Re: Tracking the progression inside a conversation
Hi,
Assign methods to a Dialogue System Events component's OnConversation and OnConversationLine, or add the same as script methods:
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++;
}
-
- Posts: 24
- Joined: Fri Mar 13, 2020 1:30 pm
Re: Tracking the progression inside a conversation
Thanks. Of course I did not think about simply checking if the speaker was the player.
Re: Tracking the progression inside a conversation
Happy to help!
-
- Posts: 24
- Joined: Fri Mar 13, 2020 1:30 pm
Re: Tracking the progression inside a conversation
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?
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?
Re: Tracking the progression inside a conversation
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:
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:
Your Script fields could look like this, which is easier to understand than conversation IDs:
And you can use the "..." dropdowns, so you don't have to type anything.
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
- Played.PrivateHart
- Played.SergeantGraves
- Played.Terminal
Your Script fields could look like this, which is easier to understand than conversation IDs:
Code: Select all
Variable["Played.PrivateHart"] = true
-
- Posts: 24
- Joined: Fri Mar 13, 2020 1:30 pm
Re: Tracking the progression inside a conversation
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.
But how do I access the current variable value?
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.
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("/", ".");
Code: Select all
bool played = DialogueManager.masterDatabase.GetVariable("Played." + convName).InitialValue;
So how do I access it?? I don't know. I'm quite lost here.
Re: Tracking the progression inside a conversation
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").
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;
-
- Posts: 24
- Joined: Fri Mar 13, 2020 1:30 pm
Re: Tracking the progression inside a conversation
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.
Re: Tracking the progression inside a conversation
Glad to help!