Author Topic: Specifying which option in a command segment to use..  (Read 1033 times)

Noodle-Impasta

  • Guest
Specifying which option in a command segment to use..
« on: October 12, 2019, 01:46:23 PM »
I have searched high and low, and i cant find clear directions on how to chose what option in a command segment is used when calling it from another command.

Here is the scenario:
I want to call the command "XYZ [1;2;3]" from another command. but i want to select option 2.

Based on the following info, I assume that i have to select Other > VoiceAttack Action > Execute Another Command and then select Execute by name and then Type in exactly what i would say to activate the correct IF statement in the command.

Quote
VoiceAttackHelp.pdf page 38
'Execute Another Command'
...
Note – If you are trying to execute a multipart/dynamic command by name, you must pick one of the commands that will be used (for instance, if you have a multipart command labeled, 'test;test [all;something]', you can just put, 'test' in the box.
...

Quote
VoiceAttackHelp.pdf page 138
{CMDSEGMENT:segment} – If your command contains, ‘dynamic command sections’
(see, ‘Dynamic Command Sections’ in the, ‘Command Screen’ documentation above), you
can retrieve specific portions of the spoken command, indicated by its numeric position.
This will allow you to make more precise decisions based on what was spoken.
For instance, let’s say you have a complex dynamic command that you use to build several
kinds of items like this:
‘build [1..10][bulldogs;wolves;strikers][please;]’
Then, you say, ‘build 5 bulldogs’ to execute that command. To find out what was built, you
can check {CMDSEGMENT:2} (note that the specified, ‘segment’ is zero-based. So, the
first segment is 0. The second is 1, and so on). The rendered value will be, ‘bulldogs’.
Then, you can find out how many items to build by checking {CMDSEGMENT:1}. The
rendered value will be, ‘5’ (which you can convert and use in a loop, for instance). For
bonus points, you can check {CMDSEGMENT:3} and see if, ‘please’ was spoken and then
thank the user for being so polite (or chide them if they didn’t say, ‘please’) ;)

On page 38 of the help PDF, in that same note as quoted above, could be additional information that if there are multiple choices in a command segment, that typing it out with that preferred choice will pass it on to any part of the command that uses it.

So in my example above, Using "Execute by name" and typing "XYZ 2" (without the "" of course) would activate any conditional line in the command that used option "2".

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Re: Specifying which option in a command segment to use..
« Reply #1 on: October 12, 2019, 05:10:34 PM »
Fire [1..3]

Code: [Select]
Set Text [Fire] to '{CMDSEGMENT:1}'
Begin Text Compare : [Fire] Equals '1'
    Execute command, 'Fire 1' (by name)
    Say, 'Fire 1'
End Condition - Exit when condition met
Begin Text Compare : [Fire] Equals '2'
    Execute command, 'Fire 2' (by name)
    Say, 'Fire 2'
End Condition - Exit when condition met
Begin Text Compare : [Fire] Equals '3'
    Execute command, 'Fire 3' (by name)
    Say, 'Fire 3'
End Condition - Exit when condition met

There are 2 segments to this command.
Fire is {CMDSEGMENT:0}

[1..3] is {CMDSEGMENT:1}

If that's not what your asking, let me know.





Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: Specifying which option in a command segment to use..
« Reply #2 on: October 12, 2019, 07:21:56 PM »
As iceblast pointed out, you need to use the "Execute by name (Advanced)" option, which will pass information along to the "{CMD}" and "{CMDSEGMENT}" tokens as if you spoke the command (note that "{CMDACTION}" will still reflect how the initial command in the chain was executed; E.G. if you have the first command mapped to a keypress, the "{CMDACTION}" token in the second command will also have the value of "Keyboard").

Quote from: VoiceAttackHelp.pdf v1.8+ page 35, 'Execute Another Command'
There are two options for executing other commands. The first option allows you to
select an existing command from a list. This is the safest way to execute other
commands, since VoiceAttack knows ahead of time about any loops that may be
encountered.
The second option (designated as an, 'advanced' feature) lets you select a command
to execute by name (replacement tokens are supported). If a name of a command that
exists is given, a simple loop check is done to make sure you will not potentially freeze
up or crash VoiceAttack. If the referenced command does not exist (or if a
replacement token is used) VoiceAttack will be unable to make the loop check, leaving
you at risk for an infinite loop. Use this feature at your own peril:)
Note – If you are trying to execute a multipart/dynamic command by name, you must
pick one of the commands that will be used (for instance, if you have a multipart
command labeled, 'test;test [all;something]', you can just put, 'test' in the box.