Dialogue->Variables.. Change it from a script.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

Dialogue->Variables.. Change it from a script.

Post by Japtor »

Hi,

I was wondering if there is a way to access a variable inside Dialogue->Variables and be able to change its value via a script inside any game object.

Thanks,
Javier.
User avatar
Tony Li
Posts: 22058
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue->Variables.. Change it from a script.

Post by Tony Li »

Hi Javier,

Yes, use DialogueLua.GetVariable() and SetVariable():

Code: Select all

using PixelCrushers.DialogueSystem;
...
int score = DialogueLua.GetVariable("Score").AsInt;
score = score + 50;
DialogueLua.SetVariable("Score", score);
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

Re: Dialogue->Variables.. Change it from a script.

Post by Japtor »

Hi,

Thanks for the help! It worked! :)
User avatar
Tony Li
Posts: 22058
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue->Variables.. Change it from a script.

Post by Tony Li »

Great! Glad to help.
Post Reply