Importing Gamespace Variable to Dialogue System

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
GUmlauf
Posts: 1
Joined: Tue Feb 10, 2015 12:17 pm

Importing Gamespace Variable to Dialogue System

Post by GUmlauf »

I feel this is a dumb question, but I've been looking around the documentation for a while and I can't find what I'm looking for.  Quite simply, I want to take a public variable existing in a C# MonoBehavior and set one of the Dialogue System's Lua variables equal to that value.  I've seen functions such as FPPlayerLuaBridge, but I'm not storing this variable in any supported third-party system and I need a generic LuaBridge, which doesn't seem to exist.  I'm pretty sure I'm just missing something basic; can I make a sequencer command that doesn't have to return a void?  Is there a built-in function to do this that I'm just not seeing?
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Importing Gamespace Variable to Dialogue System

Post by Tony Li »

Hi,



Use DialogueLua.SetVariable. For example:

using PixelCrushers.DialogueSystem;



bool myValue = true;



DialogueSystem.SetVariable("MyValue", myValue);

If you want to go the other way (set a C# variable from inside Lua code), you can register your own C# method as a Lua function.



If you want to set the variable before or after a certain Dialogue System operation, such as the start of a conversation, you can add a method that handles one of the Dialogue System's script messages.
Post Reply