[Solved]How to get variable value?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Evgeny
Posts: 16
Joined: Sun Mar 13, 2016 11:18 am

[Solved]How to get variable value?

Post by Evgeny »

I'm set Variable["EndFirstDialog"] = true in Dialogue Conversation Script field.
How to get this value in my c# script?
Last edited by Evgeny on Wed Mar 23, 2016 9:54 am, edited 1 time in total.
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to get variable value?

Post by Tony Li »

Hi,

Code: Select all

using PixelCrushers.DialogueSystem;
...
bool myValue = DialogueLua.GetVariable("EndFirstDialog").AsBool;
Evgeny
Posts: 16
Joined: Sun Mar 13, 2016 11:18 am

Re: How to get variable value?

Post by Evgeny »

Thnx! :) Next question :)

How to receive in Lua value of a variable from C#?
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to get variable value?

Post by Tony Li »

Hi,

DialogueLua.SetVariable():

Code: Select all

DialogueLua.SetVariable("EndFirstDialog", true); 
EVG
Posts: 27
Joined: Sun Jul 04, 2021 4:55 pm

Re: [Solved]How to get variable value?

Post by EVG »

Can you please tell me how to listen for a change in a variable?
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: [Solved]How to get variable value?

Post 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.
Post Reply