DialogueSystemTrigger and custom condition

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

DialogueSystemTrigger and custom condition

Post by fkkcloud »

Hi,

With DialogueSystemTrigger's Required condition,

How can I use my customized variable from my custom class/instance?
For example, I have a class called GameProgressManager and it has a bool variable "IsTutorialClear`.

I want to check this specific instance's variable like how usual c# does:

Code: Select all


if (GameObject.FindObjectByType<GameProgressManager>().IsTutorialClear)
{
	return true; // then this becomes one of the condition? like one of Lua Condition?
}

then this becomes one of the condition? like one of Lua Condition?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: DialogueSystemTrigger and custom condition

Post by Tony Li »

Hi,

Register a Lua function (Tutorial). For example, add something like this to your GameProgressManager script

Code: Select all

void Awake()
{
    Lua.RegisterFunction("IsTutorialClear", this, SymbolExtensions.GetMethodInfo(() => IsTutorialClear()));
}

public bool IsTutorialClear()
{
    return GameObject.FindObjectByType<GameProgressManager>().IsTutorialClear;
}
Then add IsProgressClear() to the Dialogue System Trigger's Conditions > Lua Conditions. If you don't want to have to type it, you can define a Custom Lua Function Info asset. Then it will appear in the "..." dropdowns under "Custom".
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: DialogueSystemTrigger and custom condition

Post by fkkcloud »

Exactly what I need!
Post Reply