PlayMaker: iterate through DS variables?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

PlayMaker: iterate through DS variables?

Post by Abelius »

Hi there,

I'd be interested in a PlayMaker action to iterate through all variables in a database and build a (PlayMaker) array with their names.

My ultimate objective would be to parse through the contents of the resulting array in search of specific text patterns, getting the DS variable names that meet that criteria.

So, I'm wondering if there's some code I could use to make a custom PlayMaker action for that purpose?

Thank you.
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: PlayMaker: iterate through DS variables?

Post by Tony Li »

Hi,

If you don't mind digging into C# a bit, this code will iterate through all variables defined in your dialogue database:

Code: Select all

using PixelCrushers.DialogueSystem; // Put at top of script.
...
foreach (var variable in DialogueManager.masterDatabase.variables) {
    Debug.Log("Variable: " + variable.Name);
}
If you want to get their current values:

Code: Select all

foreach (var variable in DialogueManager.masterDatabase.variables) {
    Debug.Log(variable.Name + " is " + DialogueLua.GetVariable(variable.Name).asString);
}
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: PlayMaker: iterate through DS variables?

Post by Abelius »

Thank you, I'll try with those and see if I can put an action together. :P
Unity 2019.4.9f1
Dialogue System 2.2.15
Post Reply