Author Topic: Saved Variables Only Saving on Specific Profile Exit  (Read 2035 times)

TwilightThrenody

  • Newbie
  • *
  • Posts: 4
Saved Variables Only Saving on Specific Profile Exit
« on: September 21, 2021, 08:26:34 PM »
VoiceAttack v1.8.9 64-bit (non-Steam) on Windows 10 21H1

I'm currently working on a profile for Final Fantasy XIV Online, where I need to have the profile remember which class/job my character has when starting up. I use a separate profile per class, which inherit commands from the main profile for non-class actions. I wanted to use a saved variable on a 'data' profile that would serve to set my class to the one saved from my last class switch, but I ran into a rather frustrating issue:

The saved variable only saves to disk when VoiceAttack is closed with that data profile active. For example, I save Dark Knight as my class during testing, close VoiceAttack on that profile, and then reload. It works fine; however, I then saved it to Paladin, switched to the Paladin class profile, and upon exiting and relaunching VoiceAttack, it says the value is Dark Knight. This obviously presents a major issue, and I've tested it with my Minecraft profile as well. I save what weapon I use to a variable to recall on reload, but if I exit VoiceAttack on a different profile, it only remembers the saved value from prior to setting it, not the one I just saved. Surely I don't need to be careful about which profile I exit on, right?

Command Structure:
(Game - FINAL FANTASY XIV Online) : Set Class to Dark Knight -> (Game - FINAL FANTASY XIV Online | Class Database) : Startup Command -> (Game - FINAL FANTASY XIV Online | Dark Knight)

From class switch command:
Code: [Select]
Set text [currentClass] to 'Game - FINAL FANTASY XIV Online | Paladin'
Switch to profile, 'Game - FINAL FANTASY XIV Online | Class Database'

From startup on Class Database profile:
Code: [Select]
#Startup to pull saved class data and swap to class profile.
Begin Integer Compare : [FFXIV.isStartup] Equals 1
  Set text [savedClass] to [Saved Value]
  Set integer [FFXIV.isStartup] value to 0
#When switching classes, record to saved value.
Else
  Set text [savedClass] to [currentClass] (save value to profile)
End Condition
Switch to profile, '{TXT:savedClass}' (by name)

The reason I have it set up this way with an 'interchange' profile is because I know that variables can only be saved per profile and not globally. For instance, if I cut out the Class Database profile and just use the main profile, the inherited commands that use 'save to profile' would save it to my class profile rather than the main one, which would cause each class profile to have a different idea of what the saved class actually is.

The VoiceAttack software has helped me immensely in using my computer with my RSI disability in both hands. Any help would be greatly appreciated!

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Saved Variables Only Saving on Specific Profile Exit
« Reply #1 on: September 21, 2021, 08:54:20 PM »
I'll need to take a look at that to see what's going on.  The intent was that the values would be persisted when either the profile is changed or if the application is closed.

Thanks for the heads up!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Saved Variables Only Saving on Specific Profile Exit
« Reply #2 on: September 21, 2021, 09:11:23 PM »
If you have a value that doesn't change very often (E.G. not several times per minute), you could consider writing it to a text file instead.

The "Write Text to a File" action combined with the "{TXT:}" token could store your value, while the "Value from file/URI" option of the "Set a Text Value" could retrieve it.

This way you can access the value independent of the active profile, without having to switch to another profile

Having a text file for each value is certainly less self-contained, but it's a relatively simple method for cross-profile storage. Though, obviously, you wouldn't want to store the files on a hard drive that spins down regularly


Alternatively, as a temporary workaround, you could set up a command that runs when you unload your other profiles using the "Execute a command each time this profile is unloaded" option at the profile level for those profiles, containing
Code: [Select]
Begin Text Compare : [{NEXTPROFILE}] Equals ''
    Switch to profile, 'Game - FINAL FANTASY XIV Online | Class Database'
    Pause 1 second
End Condition
Which will switch to what I understand to be the profile you're attempting to store the values in, before shutting down.

The pause is required for the process to complete successfully, on my machine.

TwilightThrenody

  • Newbie
  • *
  • Posts: 4
Re: Saved Variables Only Saving on Specific Profile Exit
« Reply #3 on: September 22, 2021, 10:31:55 AM »
Thank you for the quick response! I tried using the text file paging method and it works perfectly and has solved my issue. I'd love to see a fix soon though that doesn't make this method necessary (I like everything self-contained and tidy).