How to get ALL runtime variables?
How to get ALL runtime variables?
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?
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
Dialogue System 2.2.15
Re: How to get ALL runtime variables?
Hi,
It's possible in C# but not yet in PlayMaker. I'll add those to the PlayMaker integration this week.
It's possible in C# but not yet in PlayMaker. I'll add those to the PlayMaker integration this week.
Re: How to get ALL runtime variables?
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?
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
Dialogue System 2.2.15
Re: How to get ALL runtime variables?
Hi,
Yes, the PlayMaker Support unitypackage should work fine with your DS version.
Yes, the PlayMaker Support unitypackage should work fine with your DS version.
Re: How to get ALL runtime variables?
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?
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?
Re: How to get ALL runtime variables?
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.
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?
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.
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
Dialogue System 2.2.15
Re: How to get ALL runtime variables?
I'll add a GetVariableType action this week.
Re: How to get ALL runtime variables?
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).
DS_PlayMakerSupport_2022-07-14.unitypackage
It will raise an event for the variable's type (bool, number, string, or other).
Re: How to get ALL runtime variables?
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?
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
Dialogue System 2.2.15