Page 1 of 1

How to access to variables ?

Posted: Thu Aug 04, 2016 11:30 am
by jghesquiere
Hello,

I'm new to Dialogue System. I use Articy:Draft and I use templates.

I want to know how to access to the global variables in the SequencerCommand templates scripts.

The only thing I found is, for exemple : PixelCrushers.DialogueSystem.DialogueLua.GetVariable("Test");

I want to access to the global variables and to the actors variables.

Can you explain me how to do it ?

Thank you very much !

:)

Re: How to access to variables ?

Posted: Thu Aug 04, 2016 3:11 pm
by Tony Li
Hi,

Thanks for using the Dialogue System!

You're almost there.

For convenience, at the top of your sequencer command script, add:

Code: Select all

using PixelCrushers.DialogueSystem; 
You can determine variable names by looking on the Dialogue Editor window's Variables tab. When converted from articy, they have the format variablegroup.variablename. The Dialogue System uses Lua internally. Lua is a dynamically-typed language, which means a variable can store any data type (Number, Text, Boolean, etc.). When you get the variable value in a C# or UnityScript script, you should specify the type at the end of DialogueLua.GetVariable(). For example:

Code: Select all

int score = DialogueLua.GetVariable("MyGlobals.Score").AsInt;
bool isAlive = DialogueLua.GetVariable("MyGlobals.Alive").AsBool;
float cost = DialogueLua.GetVariable("CurrencyVariables.DollarCost").AsFloat;
string secretPhrase = DialogueLua.GetVariable("Secrets.TheSecretPhrase").AsString;
To get the value of an actor field, use DialogueLua.GetActorField():

Code: Select all

int age = DialogueLua.GetActorField("Player", "Age").AsInt;
If you have any other questions about this, just let me know!

Re: How to access to variables ?

Posted: Fri Aug 05, 2016 9:06 am
by jghesquiere
Awesome, thank you !!

Re: How to access to variables ?

Posted: Fri Aug 05, 2016 9:32 am
by Tony Li
Happy to help! If you have any questions about those function calls, just let me know.

Re: How to access to variables ?

Posted: Wed Aug 17, 2016 5:04 am
by jghesquiere
Hello,

I have a new question about the SequencerCommand.
As you know I use Articy:Draft with Dialogue System.
In Articy, I have made a HUB with a custom template :

Image

- Sequence : LoadScene();
- Scene : DropDown with strings

And in Dialogue System : SequencerCommandLoadScene.cs

I don't want to have to type in the Sequence field : LoadScene("MainMenu"); or LoadScene("Salle5"); etc...
I want to just set the good field of the dropdown list.

Currently I have this :

Code: Select all

using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;
using UnityEngine.SceneManagement;

namespace PixelCrushers.DialogueSystem.SequencerCommands {

	public class SequencerCommandLoadScene: SequencerCommand {
		public void Start() {
			SceneManager.LoadScene(GetParameter(0));
			Stop();
		}
	}
}
But I want to get the parameter "Scene" from the current HUB template.

Is it possible ?

Thank you.

Re: How to access to variables ?

Posted: Wed Aug 17, 2016 8:44 am
by Tony Li
Yes, you should be able to modify it as shown below. I'm out of the office, so I'm not able to test it. There might be typos.

In the articy Converter window, make sure that you're importing dropdowns as strings, not ints. I believe the dropdown defaults to int.

Code: Select all

using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;
using UnityEngine.SceneManagement;

namespace PixelCrushers.DialogueSystem.SequencerCommands {

    public class SequencerCommandLoadScene: SequencerCommand {
        public void Start() {
            var currentEntry = DialogueManager.CurrentConversationState.subtitle.dialogueEntry;
            var dropdownValue = Field.LookupValue(currentEntry.fields, "Scene");
            SceneManager.LoadScene(dropdownValue);
            Stop();
        }
    }
}

Re: How to access to variables ?

Posted: Wed Aug 17, 2016 11:01 am
by jghesquiere
OK thank you. It works very well.

Re: How to access to variables ?

Posted: Wed Aug 17, 2016 11:38 am
by Tony Li
Glad I could help!