Speaker and Listener watches?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Speaker and Listener watches?

Post by Abelius »

This is gonna look like a newbie question, but I didn't find anything on the forum.

Anyway... how can I add a watch on the Watches tab to figure out the current speaker and listener values of the running dialogue entry in an active convo?

I know I need to write a LUA expression there, but those things are definitely not "public" variables and I don't know how I should refer to them.

Thanks.
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Speaker and Listener watches?

Post by Tony Li »

Hi,

The current speaker and listener aren't actually exposed to Lua. (The active conversation's actor and conversant are, in Variable["Actor"] and Variable["Conversant"].)

To get the current speaker and listener, you need to use C#: DialogueManager.currentConversationState.subtitle.speakerInfo and listenerInfo.

You could write a couple of C# methods and register them with Lua. Then put that Lua code into a watch.

Code: Select all

public string CurrentSpeaker()
{
    if (!DialogueManager.isConversationActive) return string.Empty;
    return GetActorName(DialogueManager.currentConversationState.subtitle.speakerInfo.id);
}

public string CurrentListener()
{
    if (!DialogueManager.isConversationActive) return string.Empty;
    return GetActorName(DialogueManager.currentConversationState.subtitle.listenerInfo.id);
}

public string GetActorName(int actorID)
{
    Actor actor = DialogueManager.masterDatabase.GetActor(actorID);
    if (actor == null) return "Unknown Actor ID " + actorID;
    return actor.Name;
}
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: Speaker and Listener watches?

Post by Abelius »

Ah, it seems not so trivial as I thought at first.

TBH, this is just for troubleshooting purposes. Because I plan to use up to five generic NPC actors for multiple conversants in reusable convos, so Actor and Conversant are not good enough to know where my sequencer shortcuts are being sent each line.

But not critical at all, because I'm supposed to know who is NPC3 when I'm writing the conversation anyway. Will try to satisfy my OCD though. :P

Thanks!
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Speaker and Listener watches?

Post by Tony Li »

You can also temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. This will log the speaker as every subtitle appears.
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: Speaker and Listener watches?

Post by Abelius »

Ah, perfect! Thank you.
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Speaker and Listener watches?

Post by Tony Li »

Glad to help!
Post Reply