Author Topic: Propagate command-shared variables to enqueued commands  (Read 1888 times)

Barinzaya

  • Newbie
  • *
  • Posts: 2
Propagate command-shared variables to enqueued commands
« on: January 02, 2020, 04:14:12 PM »
I would like to use command queues to enqueue multiple calls to the same command, but with different parameters. Command-shared variables seem like the perfect avenue for this; unfortunately, it seems that command-shared variables aren't propagated to commands that are enqueued. More broadly-scoped variables (e.g. global variables) don't work for this because only the last value assigned is kept (because every enqueued command refers to the same variable).

My use case is as follows: the command I want to enqueue is primarily a TTS routine, but it does some other things as well (e.g. writing the text being spoken out to a file so that it can be read by other programs for subtitling). I don't want to repeat this logic everywhere, so I'm putting the text to be spoken into a ~~text variable and executing the command directly.

The only way I was able to get this to work reliably was to stop the current TTS playback, pause briefly, and then speak the new message instead. This works as expected; however, I would like to be able to enqueue multiple different messages to be spoken (and written out to the file) one after another, in the correct order, without needing to worry about messages overlapping or canceling each other out. Command queues seem like the perfect way to accomplish this, except that I can't figure out how to pass the text to be spoken to the TTS routine.

Attached is a profile which demonstrates a (greatly simplified) version of what I'm referring to. It seems to me that upon executing the enqueue command, the ((print)) command should be called after one second, printing "Test A", and then one second later, printing "Test B". The timing works out as expected, but both times instead print "Not set".

Is this a missing feature, or is this intentional behavior? Is there a better way to accomplish this? Thanks in advance for your time.


EDIT by Pfeil: Implemented.
« Last Edit: April 18, 2020, 01:15:20 PM by Pfeil »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2824
Re: Propagate command-shared variables to enqueued commands
« Reply #1 on: January 02, 2020, 05:28:07 PM »
Thank you for heads up and the detailed information, Barinzaya.  I will need to code dive on this, as it seems that might be a possible oversight.  Unfortunately, however, I wont be able to get to this in the coming week.

Again - I appreciate you letting me know!

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2824
Re: Propagate command-shared variables to enqueued commands
« Reply #2 on: January 02, 2020, 05:51:56 PM »
I took a quick peek - Command queues are fire and forget, which means that the calling command is not the, 'parent' of the queued command.  That means that the calling command wont have access to the commands it queues after they execute.  This doesn't mean that the command-scoped variables couldn't be handed off to the queued commands - the queued commands would have their own copy of the command-scoped variables to work with and pass on, they just wont have a parent command to pass back to.  I can work from that end - does that seem like it would work for you?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2824
Re: Propagate command-shared variables to enqueued commands
« Reply #3 on: January 02, 2020, 06:40:15 PM »
Well, the code was already there to do this - commented out lol.  I'm assuming it wasn't finished because of the one-way situation.  I uncommented the code and compiled it as beta version v1.8.3.4.  I'm short on time, so, I'm not going to take this to full beta at the moment - but you want, you can give it a whirl and download this updated version from the, VoiceAttack 'unofficial' bin (standalone and Steam):

http://voiceattack.com/unofficial

and/or

http://voiceattack.com/unofficialsteam

It's just the executable - just replace your .exe with what is downloaded.  Not sure how Steam will treat the .exe with automatic updates, though.  You may want to look in here to see how to disable that:  https://forum.voiceattack.com/smf/index.php?topic=2973.0

Let me know how it goes!

Barinzaya

  • Newbie
  • *
  • Posts: 2
Re: Propagate command-shared variables to enqueued commands
« Reply #4 on: January 02, 2020, 09:38:58 PM »
I tried the unofficial build, and it works perfectly for my use case! I didn't expect the command-shared variables to work bidirectionally, given the asynchronous nature of the command queuing, and wasn't planning to try to use it that way, so this is perfectly fine for what I wanted to use it for.

Thanks a ton for the extremely quick response, and for updating with a build so quickly!

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2824
Re: Propagate command-shared variables to enqueued commands
« Reply #5 on: January 02, 2020, 10:23:25 PM »
Awesome!  Glad this fills your need.  Thanks for the feedback - this will be in the next beta and subsequent release :)