Page 1 of 1

Variables and Events for Ink integration

Posted: Fri Nov 16, 2018 10:26 am
by Senad
I am using Dialogue System with Ink.

Is there a way to read and write the global variables to and from Ink from a script?

Is there a way to through a generic event from the Ink Script like the predefined external functions? (show alert, etc.)

Thank you!! :)

Re: Variables and Events for Ink integration

Posted: Fri Nov 16, 2018 11:19 am
by Tony Li
Hi!
Senad wrote: Fri Nov 16, 2018 10:26 amIs there a way to read and write the global variables to and from Ink from a script?

Is there a way to through a generic event from the Ink Script like the predefined external functions? (show alert, etc.)
Are you talking about Dialogue System global variables, or Ink global variables?

The Ink integration lets you set Ink variables in Lua or C#. In C#, do it like this example:

Code: Select all

DialogueSystemInkIntegration.SetInkBool("variableName", true);
I'm working on the next release. I can add corresponding functions to read Ink variables, and Ink external functions to read and write Dialogue System variables.

Re: Variables and Events for Ink integration

Posted: Fri Nov 16, 2018 11:46 am
by Senad
Thank you, that was helpful.

How about raising events from within Ink Script? Something like

Code: Select all

EXTERNAL ShowAlert(x)
I would like to fire some string events that I can catch from within C#. So you know how I could go about that?

Re: Variables and Events for Ink integration

Posted: Sun Nov 25, 2018 1:11 pm
by Tony Li
I'm so sorry; for some reason I didn't get a notification that you had replied! I was just returning to this thread to let you know that the Extras page now has an updated Ink Support package with the additions you requested. This package is also in version 2.0.8, which will be released tomorrow.

To raise an event from within an Ink Script, you need to bind a C# function to Ink. For example, this is how DialogueSystemInkIntegration.cs does it with ShowAlert:

Code: Select all

story.BindExternalFunction("ShowAlert", (string message) => { DialogueManager.ShowAlert(message); });
(The variable 'story' is a reference to your Ink story.)

Re: Variables and Events for Ink integration

Posted: Sun Nov 25, 2018 3:07 pm
by Senad
Fantastic, thank you! :)

Re: Variables and Events for Ink integration

Posted: Sun Nov 25, 2018 3:30 pm
by Tony Li
Glad to help!

If I ever don't respond within 24 hours, feel free to ping me. I always try to reply within 24 hours.