Page 1 of 1

PlayMaker: iterate through DS variables?

Posted: Mon Oct 15, 2018 2:00 pm
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.

Re: PlayMaker: iterate through DS variables?

Posted: Mon Oct 15, 2018 4:18 pm
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);
}

Re: PlayMaker: iterate through DS variables?

Posted: Mon Oct 15, 2018 5:53 pm
by Abelius
Thank you, I'll try with those and see if I can put an action together. :P