Page 1 of 1

Store dialogue entry sequence in a variable?

Posted: Sun Sep 24, 2023 4:16 pm
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.

Re: Store dialogue entry sequence in a variable?

Posted: Sun Sep 24, 2023 4:35 pm
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.

Re: Store dialogue entry sequence in a variable?

Posted: Sun Sep 24, 2023 5:27 pm
by Abelius
Um... sorry. I've written some nonsense. :?

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

Image

Re: Store dialogue entry sequence in a variable?

Posted: Sun Sep 24, 2023 7:31 pm
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;
}

Re: Store dialogue entry sequence in a variable?

Posted: Sun Sep 24, 2023 8:42 pm
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.

Re: Store dialogue entry sequence in a variable?

Posted: Mon Sep 25, 2023 9:07 am
by Tony Li
It sounds like you have it working now. If you need any help with changes, let me know.

Re: Store dialogue entry sequence in a variable?

Posted: Mon Sep 25, 2023 9:43 am
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: