Page 1 of 1

[Solved]How to get variable value?

Posted: Mon Mar 21, 2016 6:19 am
by Evgeny
I'm set Variable["EndFirstDialog"] = true in Dialogue Conversation Script field.
How to get this value in my c# script?

Re: How to get variable value?

Posted: Mon Mar 21, 2016 8:51 am
by Tony Li
Hi,

Code: Select all

using PixelCrushers.DialogueSystem;
...
bool myValue = DialogueLua.GetVariable("EndFirstDialog").AsBool;

Re: How to get variable value?

Posted: Tue Mar 22, 2016 2:37 am
by Evgeny
Thnx! :) Next question :)

How to receive in Lua value of a variable from C#?

Re: How to get variable value?

Posted: Tue Mar 22, 2016 8:48 am
by Tony Li
Hi,

DialogueLua.SetVariable():

Code: Select all

DialogueLua.SetVariable("EndFirstDialog", true); 

Re: [Solved]How to get variable value?

Posted: Wed Jul 07, 2021 5:21 pm
by EVG
Can you please tell me how to listen for a change in a variable?

Re: [Solved]How to get variable value?

Posted: Wed Jul 07, 2021 6:25 pm
by Tony Li
You can use a Lua observer or manually check it using DialogueLua.GetVariable(). If you use a Lua observer, avoid using LuaWatchFrequency.EveryUpdate since this will run code every update. Instead, check it when it's important to check, such as at the end of conversations.