Store dialogue entry sequence in a variable?

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

Store dialogue entry sequence in a variable?

Post by Abelius »

Hi there,

For debugging purposes, I'd like to store in a string variable the contents of the current dialogue entry.

That way I would be able to show on the next dialogue line what I've run in the previous one.

Is it possible?

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

Re: Store dialogue entry sequence in a variable?

Post by Tony Li »

Hi,

You could get it from the subtitle panel's subtitle text UI element.

Or you could download this patch:

DS_PlayMakerPatch_2023-09-24.unitypackage

Then use a Dialogue System Events To PlayMaker component and listen for the OnConversationLine event. The patch above makes this event include the subtitle text as the string data connected to the event.
User avatar
Abelius
Posts: 312
Joined: Fri Jul 21, 2017 12:45 pm

Re: Store dialogue entry sequence in a variable?

Post by Abelius »

Um... sorry. I've written some nonsense. :?

What I want to store are the contents of the Sequence...:

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

Re: Store dialogue entry sequence in a variable?

Post by Tony Li »

Can you use a little C#? If so:

Code: Select all

string sequence = DialogueManager.currentConversationState.subtitle.sequence;
Or, in a script on the Dialogue Manager, you can add an OnConversationLine() method:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    string sequence = subtitle.sequence;
}
User avatar
Abelius
Posts: 312
Joined: Fri Jul 21, 2017 12:45 pm

Re: Store dialogue entry sequence in a variable?

Post by Abelius »

I've used the OnConversationLine method. Turns out I did something very similar to send every subtitle ran to the player.log file.

However, I've needed to make a modification so that only the last non-dialogue entries are saved:

Code: Select all

if (this.subtitle != null)
{
    sequence = (conversation != null) ? conversationState.subtitle.dialogueEntry.currentSequence : "";
    DialogueLua.SetVariable("LastSequence", sequence);
}
That is, I'm discriminating which dialogue entry's sequence to save, because I'm not interested in the ones that are used to display dialogue, only the ones that I use for animation shortcuts, such as the one above.

So, it's working.

However, I think it would be ideal to trigger this from a LUA script command instead, so it could be run on demand before jumping to the next entry, even when the sequence contains an immediate Continue() command. And then use [var=xxx] on the next entry, with the peace of mind that it won't be overwritten until you run the LUA command again.

Bonus points, you know. :P

Edit: I'm reading that code I've written and I'm realizing it doesn't look good. I should have used == instead of !=. So I don't know how the hell it's working regardless. :lol:

Edit 2: I've removed the conditional so it's run on every line, and it turns out the variable stored is still the one from the previous entry. That must mean it takes a while to store it back to DS, which serves my purpose, funnily enough.
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Store dialogue entry sequence in a variable?

Post by Tony Li »

It sounds like you have it working now. If you need any help with changes, let me know.
User avatar
Abelius
Posts: 312
Joined: Fri Jul 21, 2017 12:45 pm

Re: Store dialogue entry sequence in a variable?

Post by Abelius »

Yes, thank you. And sorry for the mess of my post. I need to learn to experiment more, then actually write. And also trying to avoid working at 2 am. :roll:
Unity 2019.4.9f1
Dialogue System 2.2.15
Post Reply