Author Topic: Persistent variables  (Read 1933 times)

jcdick1

  • Jr. Member
  • **
  • Posts: 55
Persistent variables
« on: April 09, 2024, 08:28:36 AM »
I have a profile that has custom variables that have the potential to be created, changed or recalled based on on an event every time I use the profile.  I'd like to have these variables receive their value upon creation, but then keep that value permanently across VA sessions.  In order to do that, though, I think I have to have a Conditional block that contains "If {variable_name} is blank ..." twice:

Code: [Select]
If {variable_name} is blank - not set considered blank
Code: [Select]
    Set {variable_name} to [saved value] (from the profile) variable not in memory so check for value from profile. Successful retrieval from profile should skip next section.
Code: [Select]
Else if {variable_name} is blank - not set considered blank variable is still blank/not set because it wasn't found in the profile either.
Code: [Select]
    Do process to create {variable_name} value and save value to profile
Code: [Select]
End
Code: [Select]
Do action using {variable_name} value
Are there any suggestions on a better way to do it than two "if variable is blank" statements to have VA check its current memory and/or profile-stored values to keep a variable persistent essentially in perpetuity?

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 264
  • Upstanding Lunatic
    • My AVCS Homepage
Re: Persistent variables
« Reply #1 on: April 09, 2024, 12:02:56 PM »
Whenever you load your profile, such global variables will be not set.

You can therefore bypass any initial check for 'not set' and proceed to retrieve the saved value from the profile, assuming that you save to profile any values set to this variable each time.

Then you can check if it is still 'not set' and provide a means to set this variable to some default value.

This 'initialization' style command could be called automatically whenever you switch to the profile through this Profile's Options menu under the 'Profile Exec' tab, setting this as the command to execute each time this profile is loaded:

jcdick1

  • Jr. Member
  • **
  • Posts: 55
Re: Persistent variables
« Reply #2 on: April 09, 2024, 12:27:10 PM »
Well, the variables being created are named using another variable embedded in that variable name.  In this case, I'm using the Elite: Dangerous VA plugin EDDI which generates VA variables for use in VA.

Whenever an NPC sends a message, the event triggers EDDI to generate a variable containing the name of the sender, called
Code: [Select]
{TXT:EDDI message received sender} 
I am using this variable to create a process to assign a unique TTS voice to each individual NPC, randomly assigned from a pool of 22 voices.  My process is using a variable called
Code: [Select]
{TXT:{TXT:EDDI message received sender} voice} 
This results in a number of unique variables based on the sender's name.  So when an NPC named "System Authority Vessel" sends me a message, VA has a TXT variable created "internally" called
Code: [Select]
{TXT:System Authority Vessel voice}the value of which would be "Dave" or "Zira" or "Russell" or whatever, corresponding to the appropriate voice.

All of these variables are only ever addressed in the profile using that embedded variable name.  I can get VA to use the same voice for each NPC during the same session but I can't get it to recall the appropriate voice assignment that had been saved to the profile from previous sessions so that whenever {TXT:{TXT:EDDI message received sender} voice} equals {TXT:System Authority Vessel voice}, it uses the same voice it used yesterday or three weeks ago.

Code: [Select]
7/4 11:53 PM - Albert - Joey
7/4 11:58 PM - Hope City - Zira
7/4 11:59 PM - Hope City - Zira
7/4 11:59 PM - Hope City - Zira
7/4 11:59 PM - System Authority Vessel - Heera
8/4 7:30 PM - Hope City - Kimberly
8/4 7:36 PM - Loke - Salli
8/4 7:37 PM - Sisyphus - Brian
8/4 7:37 PM - Heine the Elder - Joey

As you can see in that table that is generated using the relevant variables, "Hope City" used "Zira" repeatedly during first period of play, but was subsequently assigned the "Kimberly" voice the next day.

When the event occurs, I need VA to check memory for the existence of the variable, which it does and either assigns a voice because its a new iteration of the variable, or re-uses the voice because it had already "seen" the name. I am now trying to figure out how to add a "check the profile and load the value if its there" step as well so that it doesn't assign a new voice in a new gaming session.  Isn't that what saving variables values to the profile is for?

Edit:  updated with example info