Hi ! am a noob with this amazing dialogue system and i follow the video Connecting Your C# Methods to Lua, but i still dont understand how can i have access to my fonction on a specific node in the dialogue. Like i want to my npc start my fonction Test(),when i click on change season in the dialogue system. My npc scrip is on a gameobject npc
Sorry for the noob question but i cant find how to do it and thank you very mush in advence.
How to reference a fonction to the dialogue system
Re: How to reference a fonction to the dialogue system
Hi,
Thanks for using the Dialogue System!
I'll assume your HoraeNpc script is on your NPC GameObject. Add these methods to the script:
Then you can use Test() in your dialogue entry node's Script field.
Thanks for using the Dialogue System!
I'll assume your HoraeNpc script is on your NPC GameObject. Add these methods to the script:
Code: Select all
void OnEnable()
{
// Make Test() available to Lua:
Lua.RegisterFunction(nameof(Test), this, SymbolExtensions.GetMethodInfo(() => Test()));
}
void OnDisable()
{
Lua.UnregisterFunction(nameof(Test));
}
Re: How to reference a fonction to the dialogue system
OMG that was so simple ! and its working thank you very much for you replay !
Re: How to reference a fonction to the dialogue system
Happy to help!
Keep in mind that Lua functions are registered globally. If you register a function named Test() on an NPC named Horae, you shouldn't register a function Test() on another GameObject at the same time.
Keep in mind that Lua functions are registered globally. If you register a function named Test() on an NPC named Horae, you shouldn't register a function Test() on another GameObject at the same time.