I know that we have the feature DialogueManager.ResetDatabase that resets the variables and quests to their initial values.
Would it be possible to target specific groups of variables to be reset while keeping the values of other. I have some variables that change each run of my roguelike and others that are permanent progression.
Reset specific variable groups
Re: Reset specific variable groups
Hi,
You could just loop through the variables:
You could just loop through the variables:
Code: Select all
foreach (var variable in DialogueManager.masterDatabase.variables)
{
if (variable.title.StartsWith("rundata."))
{
if (variable.type == FieldType.Number) DialogueLua.SetVariable(variable.title, 0);
else DialogueLua.SetVariable(variable.title, "");
}
}
-
- Posts: 10
- Joined: Wed Jun 14, 2023 10:33 am
Re: Reset specific variable groups
OK, so I would have to manually put in the string or number I want to reset to. There is no GetInitialValue or something like that I can use?
EDIT:
I think I found it thanks for the help.
EDIT:
I think I found it thanks for the help.
Code: Select all
foreach (var variable in DialogueManager.masterDatabase.variables) {
if (variable.Name.StartsWith("rundata.")) {
if (variable.Type == FieldType.Number) DialogueLua.SetVariable(variable.Name, variable.InitialFloatValue);
else if (variable.Type == FieldType.Text) DialogueLua.SetVariable(variable.Name, variable.InitialValue);
else if (variable.Type == FieldType.Boolean) DialogueLua.SetVariable(variable.Name, variable.InitialBoolValue);
}
}
Re: Reset specific variable groups
Yup, that's exactly what I was going to type initially, and then I totally forgot.