Author Topic: Playing sounds, setting variables, and guids, oh my...  (Read 4640 times)

mtm

  • Newbie
  • *
  • Posts: 6
Playing sounds, setting variables, and guids, oh my...
« on: March 16, 2020, 05:55:24 PM »
I'm writing a fairly complex voice attack profile for a game and have been quite impressed with the level of complexity and freedom Voice Attack allows me.  I recently started playing with inline functions.  As a software engineer with a background including c++ and java, the transition to c# is easy and more comfortable to code in than using the gui for me.  Also I had a particular command which was taking over 50s normal, ported to inline c# it now takes 0.3s, so I'm sold on putting what I can in to c#.

I don't see a few pieces of functionality which I'd really like to have.  I have workarounds for these things, but if I'm missing something and they are possible using inline functions, I'd love to know how.

I have a command which is essentially a step by step configuration using voice prompts w/ user responses.  For this one I extensively use Play [random] sound, Say with tts and Wait for spoken response.  Currently I'm executing these by calling a utility command while passing parameters back and forth using the ~~ prefix.  That all works fine, but it'd be far more convenient (and I suspect slightly faster) if I could call them directly from c#.  (I do realize the docs have an example of playing sound using System.Media.SoundPlayer, but I figure since I'm using VA it'd be easier to use the built in functionality to play sounds and run voice recognition.  I'm not trying to re-create core VA functionality from scratch within VA if I can help it.)

Speaking of calling other commands from within inline functions, I had a hard time getting that to work.  Eventually I got it going, but while testing I gave using execute command by Guid a shot, thinking it would be more reliable and protect against name changes at the same time, but had no luck at all.  First issue being I couldn't find a way to look up the Guid of an existing command.  Eventually I exported my profile and looked up the Guid manually in the xml, created a "guid?" field with the value and tried executing the command that way.  I couldn't get it to work.  Tried with a few commands and no luck.  Just kept getting the "unable to find command" error.

I also tried getting the guid of the current command (inserting debug code in to the command I wanted) using VA.Command.InternalID(), but it results in a "Not set" message when I write to the log.  Perhaps that's related to my inability to use the guid to execute commands?  Not sure.

Once the user finishes the configuration step, I then take the data I gathered and store it in variables which are saved to the profile to be loaded later.  I know I can get and set variables from inline functions, but is there a way to save the value to the profile directly?  And on a related note, can I load variables using "retrieve saved value" from inline functions?  It would be nice to be able to convert my init script over to an inline function.

Any advice or pointers to where I can find info about this would be very much appreciated.  I've been all over the pdf documentation, though I could easily have missed something.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Playing sounds, setting variables, and guids, oh my...
« Reply #1 on: March 16, 2020, 06:47:28 PM »
I also tried getting the guid of the current command (inserting debug code in to the command I wanted) using VA.Command.InternalID(), but it results in a "Not set" message when I write to the log.  Perhaps that's related to my inability to use the guid to execute commands?  Not sure.
As documented in the "Command-level flags" subsection of the "VoiceAttack Author Flags" section of VoiceAttackHelp.pdf, you need to use the "<InternalID>" tag to assign a GUID manually to the commands you want to call.

is there a way to save the value to the profile directly?
No.

can I load variables using "retrieve saved value" from inline functions?
No.

mtm

  • Newbie
  • *
  • Posts: 6
Re: Playing sounds, setting variables, and guids, oh my...
« Reply #2 on: March 16, 2020, 06:59:32 PM »
That's quite helpful, thank you. I've read that section of the docs now and will set it up tonight.