How to get ALL runtime variables?

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

How to get ALL runtime variables?

Post by Abelius »

Hello Tony,

I'm a heavy user of PlayMaker but for the most part I'm relying on Dialogue System variables to save game data. Therefore, I've been using the "Get / Set Variable" actions provided with DS, among the others.

However, as development goes on, the DB is growing a lot because most of those variables are created and initialized at runtime, and scrolling down through the list in the Watchers tab is becoming impractical and a time sink.

So, I'd like to have a way to get ALL the variables to a PlayMaker hash table, one for each variable type. Not only the ones created in the editor, but the same list offered by using the "Add all runtime variables" option in the Watchers tab.

I thought the action "Get All Lua Elements" could help, but it only retrieves the names of the variables created in the editor.

For doing this, I'd need two things at a minimum:

- Retrieve all variable names, including the ones initialized at runtime so far.
- Have a way to recognize the type of each variable, so I can use the Get Variable action picking the correct type.

Is this possible?
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to get ALL runtime variables?

Post by Tony Li »

Hi,

It's possible in C# but not yet in PlayMaker. I'll add those to the PlayMaker integration this week.
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: How to get ALL runtime variables?

Post by Abelius »

Thank you, although I won't be able to update DS itself because I'm stupid and made a lot of script modifications without saving a registry of changes.

Do you think the integration package will work on my version as well as if I had the latest DS version installed?
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to get ALL runtime variables?

Post by Tony Li »

Hi,

Yes, the PlayMaker Support unitypackage should work fine with your DS version.
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to get ALL runtime variables?

Post by Tony Li »

Hi,

Back up your project and give this package a try:

DS_PlayMakerSupport_2022-07-11.unitypackage

If you get any errors with your DS version, please post them here.

This updated package adds a checkbox, ticked by default, that gets all elements including those created at runtime.

I have a question about the other request. Lua variables are "dynamically typed," which means you can treat them as numbers, Booleans, or strings. Do you need an action to determine the variable's type, or is it ok to just use it as whatever type you need?
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: How to get ALL runtime variables?

Post by Abelius »

Hi Tony,

Thanks for the package. At the end I've needed to import just the "Get All Lua Elements" action, because some of the rest, even the new scripts weren't finding some definitions, or something like that.

Anyway, I just needed that action which now retrieves all variable names. However, that's "just" what it does, so I have a list of names only.

I'd need a way to identify their type, so I can iterate and add each of them to an appropriate hash table (float, string, bool, etc).

In hindsight, I should have named them with a prefix, now I see that. Something like "bool.Flag.HomeworkDone", "string.Player.OutfitName"... but it's too late for that. :cry:

I guess I could use a "Get Variable" action using all four type variables as targets, and then which of them isn't null, but I'm afraid using that trick would still give me non-null Int and Float variables when I retrieve a DS number variable.

Some magic function to do that?
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to get ALL runtime variables?

Post by Tony Li »

I'll add a GetVariableType action this week.
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: How to get ALL runtime variables?

Post by Abelius »

Awesome!
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to get ALL runtime variables?

Post by Tony Li »

This updated package has a new GetVariableType action:

DS_PlayMakerSupport_2022-07-14.unitypackage

It will raise an event for the variable's type (bool, number, string, or other).
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

Re: How to get ALL runtime variables?

Post by Abelius »

Sorry for the long delay in testing this. It works great. :)

My only additional question would be if differentiating between Integer and Float variables would be feasible. Probably not, as both of them are identified as "Number" in DS database, right?
Unity 2019.4.9f1
Dialogue System 2.2.15
Post Reply