Direct calls from C#

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Kale
Posts: 5
Joined: Fri Nov 22, 2019 10:32 am

Direct calls from C#

Post by Kale »

Hello! I recently purchased Dialogue System and I love it, but am having trouble integrating it into my project in the way that I would like. Everything I've found deals with integrating it into projects with an actor walking around a world, using trigger volumes and such. I'm trying to use it for a menu-based game (similar to Crying Suns, for instance) and need to be able to trigger conversations from code, as well as passing variables or function calls back into code as a result of dialogue choices. Is there a good resource for that use case? Thanks in advance.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Direct calls from C#

Post by Tony Li »

Hi,

Thanks for using the Dialogue System!

To start a conversation from code, use DialogueManager.StartConversation().

You can still use Dialogue System Trigger components, too, if you prefer. A common use is to add a Dialogue System Trigger to a UI button and configure the UI button's OnClick() to call DialogueSystemTrigger.OnUse.

At runtime, the Dialogue System puts its changeable data (such as variables) in Lua. Use the DialogueLua class to access Lua values. For example:

Code: Select all

using PixelCrushers.DialogueSystem;
...
int numApples = DialogueLua.GetVariable("NumApples").asInt;
You can also register your own C# methods with Lua so you can call them in dialogue entry nodes' Conditions and Script fields.

In addition to exposing your own C# code to Lua, you can also write your own sequencer commands in C#.
Kale
Posts: 5
Joined: Fri Nov 22, 2019 10:32 am

Re: Direct calls from C#

Post by Kale »

Thank you so much! I'm off to doing fun things now. I appreciate the excellent documentation.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Direct calls from C#

Post by Tony Li »

Happy to help!
Post Reply