How to access to variables ?
-
- Posts: 10
- Joined: Thu Aug 04, 2016 10:58 am
How to access to variables ?
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 !
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 ?
Hi,
Thanks for using the Dialogue System!
You're almost there.
For convenience, at the top of your sequencer command script, add:
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:
To get the value of an actor field, use DialogueLua.GetActorField():
If you have any other questions about this, just let me know!
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;
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;
Code: Select all
int age = DialogueLua.GetActorField("Player", "Age").AsInt;
-
- Posts: 10
- Joined: Thu Aug 04, 2016 10:58 am
Re: How to access to variables ?
Awesome, thank you !!
Re: How to access to variables ?
Happy to help! If you have any questions about those function calls, just let me know.
-
- Posts: 10
- Joined: Thu Aug 04, 2016 10:58 am
Re: How to access to variables ?
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 :
- 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 :
But I want to get the parameter "Scene" from the current HUB template.
Is it possible ?
Thank you.
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 :
- 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();
}
}
}
Is it possible ?
Thank you.
Re: How to access to variables ?
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.
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();
}
}
}
-
- Posts: 10
- Joined: Thu Aug 04, 2016 10:58 am
Re: How to access to variables ?
OK thank you. It works very well.
Re: How to access to variables ?
Glad I could help!