How to set all dialouge values to true

Announcements, support questions, and discussion for the Dialogue System.
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

How to set all dialouge values to true

Post by soniclinkerman »

Hey!

I want to create a time trial mode for my game and this requires that there's no dialogue that happens.

I thought one solution could be:

When the user chooses time trial mood, ALL the dialogue conversations turn true.

Or is there another way to completely remove the dialogue conversations when in a mode like this
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to set all dialouge values to true

Post by Tony Li »

Hi,

There are a few ways you can do this.

The heavy-handed way is to kill any conversation that starts. Add a script to the Dialogue Manager that has an OnConversationStart method. In this method, stop the conversation. Example (assuming you have a function IsDemoMode):

Code: Select all

public class StopAllConversations : MonoBehaviour
{
    void OnConversationStart(Transform actor)
    {
        if (IsDemoMode())
        {
            DialogueManager.StopConversation();
        }
    }
}
Or you could assign a method to DialogueManager.IsDialogueEntryValid, which is a delegate that you can set to do extra checks:

Code: Select all

DialogueManager.IsDialogueEntryValid = CheckIfDemo;

bool CheckIfDemo(DialogueEntry entry)
{
    return !IsDemoMode();
}
Or you could make a subclass of DialogueSystemTrigger and use it instead of DialogueSystemTrigger. Override DoConversationAction():

Code: Select all

public class CustomDialogueSystemTrigger : DialogueSystemTrigger
{
    protected override void DoConversationAction(Transform actor)
    {
        if (!IsDemoMode())
        {
            base.DoConversationAction(actor);
        }
    }
}
If you want to set all Boolean variables true, you could do this:

Code: Select all

foreach (Variable variable in DialogueManager.masterDatabase.variables)
{
    if (variable.Type == FieldType.Boolean)
    {
        DialogueLua.SetVariable(variable.Name, true);
    }
}
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: How to set all dialouge values to true

Post by soniclinkerman »

The last solution you mentioned is definitely what I want. Because all the dialogue is originally false.

So I can just add this to my script and all of them will revert true. I'll try this right now
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: How to set all dialouge values to true

Post by soniclinkerman »

Also quick question. Is there a way to import the unity package Pixelcrush in code without seeing red squiggles under it?
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: How to set all dialouge values to true

Post by soniclinkerman »

This caused an error
Error.png
Error.png (60.66 KiB) Viewed 522 times
I'm trying to uninstall these imports, but can't seem to find them because I didn't take a look at where they were going to be imported
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: How to set all dialouge values to true

Post by soniclinkerman »

*UPDATE*

I deleted the packages that were causing the issue luckily and it doesn't seem like anything was affected.

Updated VS package in Unity and so far, no squiggles. I'm still having a bit of trouble figuring out how I can implement the ability to remove all triggers and dialogue.

The foreach loop worked great, but there are some instances where I added a trigger collision to a gameobject for something to happen.

I'm not sure how I can just turn off the dialogue component that's on that trigger when I'm in this new trial mode
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to set all dialouge values to true

Post by Tony Li »

What about using one of the other techniques I suggested above?
soniclinkerman
Posts: 82
Joined: Wed Mar 31, 2021 6:48 pm

Re: How to set all dialouge values to true

Post by soniclinkerman »

Doing this approoach

Code: Select all

DialogueManager.IsDialogueEntryValid = CheckIfDemo;

bool CheckIfDemo(DialogueEntry entry)
{
    return !IsDemoMode();
}
Gives me red squiggles(Which also means the red squiggles in pixelcrush importing is back).

I would like to do this since it seems like it'd work, but am unsure why it's not importing right
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to set all dialouge values to true

Post by Tony Li »

Where are the squiggles? If it's under IsDemoMenu, that's because you need to provide that function.
Post Reply