How to call Default Sequence from new custom Sequence I'm making?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
EntertainmentForge
Posts: 23
Joined: Sun Nov 29, 2020 8:50 pm

How to call Default Sequence from new custom Sequence I'm making?

Post by EntertainmentForge »

Hello!

I am making a custom Sequence that plays a facial expression for a character. And since I need to call this sequence in every NPC dialogue line it would be tedious to have to write include {{default}} every time.

So I am trying to call Default Sequence from the new custom Sequence class SequencerCommandSetExpression. But I'm running in circles trying to find a way to do it and I finally decided to ask for help.
I noticed Sequencer.PlaySequence() method but I don't know how to make it call the default one. Is there some way of doing this?

Thanks!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to call Default Sequence from new custom Sequence I'm making?

Post by Tony Li »

Hi,

Use an OnConversationLine method. For example, add a script with this method to the Dialogue Manager:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.speakerInfo.isNPC && !subtitle.sequence.Contains("{{default}}")
    {
        subtitle.sequence = "{{default}}; " + subtitle.sequence;
    }
}
You could define your own special keyword -- maybe {{nodefault}} -- to indicate that the line shouldn't incorporate the default:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.speakerInfo.isNPC && !subtitle.sequence.Contains("{{default}}" && 
        !subtitle.sequence.Contains("{{nodefault}}")
    {
        subtitle.sequence = "{{default}}; " + subtitle.sequence;
    }
}
EntertainmentForge
Posts: 23
Joined: Sun Nov 29, 2020 8:50 pm

Re: How to call Default Sequence from new custom Sequence I'm making?

Post by EntertainmentForge »

Thank you! This solved the problem. I adjusted the code a little bit and I'm gonna post here in case anyone else runs into same problem:

Code: Select all

void OnConversationLine(Subtitle subtitle)
	{
		if ((subtitle.speakerInfo.isNPC && !subtitle.sequence.Contains("{{default}}")) && subtitle.sequence.Contains("SetExpression"))
	    {
			subtitle.sequence = "{{default}}; " + subtitle.sequence;
		}
	}
I check if "SetExpression" is contained in sequence to check if line needs adding {{default}}, so I don't have to add {{nodefault}} on all other lines.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to call Default Sequence from new custom Sequence I'm making?

Post by Tony Li »

Glad to help, and thanks for sharing your solution.
Post Reply