Page 1 of 3

How to set all dialouge values to true

Posted: Wed Apr 21, 2021 8:58 am
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

Re: How to set all dialouge values to true

Posted: Wed Apr 21, 2021 11:02 am
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);
    }
}

Re: How to set all dialouge values to true

Posted: Wed Apr 21, 2021 11:10 am
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

Re: How to set all dialouge values to true

Posted: Wed Apr 21, 2021 11:12 am
by soniclinkerman
Also quick question. Is there a way to import the unity package Pixelcrush in code without seeing red squiggles under it?

Re: How to set all dialouge values to true

Posted: Wed Apr 21, 2021 11:19 am
by Tony Li

Re: How to set all dialouge values to true

Posted: Wed Apr 21, 2021 11:31 am
by soniclinkerman
This caused an error
Error.png
Error.png (60.66 KiB) Viewed 532 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

Re: How to set all dialouge values to true

Posted: Wed Apr 21, 2021 12:40 pm
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

Re: How to set all dialouge values to true

Posted: Wed Apr 21, 2021 1:52 pm
by Tony Li
What about using one of the other techniques I suggested above?

Re: How to set all dialouge values to true

Posted: Wed Apr 21, 2021 2:01 pm
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

Re: How to set all dialouge values to true

Posted: Wed Apr 21, 2021 2:08 pm
by Tony Li
Where are the squiggles? If it's under IsDemoMenu, that's because you need to provide that function.