Page 1 of 1

DialogueSystemTrigger and custom condition

Posted: Sat Dec 19, 2020 8:36 am
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?

Re: DialogueSystemTrigger and custom condition

Posted: Sat Dec 19, 2020 9:37 am
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".

Re: DialogueSystemTrigger and custom condition

Posted: Sat Dec 19, 2020 11:45 pm
by fkkcloud
Exactly what I need!