Author Topic: Possible to make {CMDSEGMENT} variable optional?  (Read 1364 times)

Richie67

  • Guest
Possible to make {CMDSEGMENT} variable optional?
« on: May 01, 2019, 09:41:05 AM »
I created a profile in which I use {CMDSEGMENT}to set a variable but I run into some difficulties in how i want to use the variable.

for example:
Quote
When I say:
Set Player [Player 1;Player 2;Player 3;Player 4;Player 5; and so on until player 30]

When this command executes, do the following sequence:
Set Text [PlayerVariable] to '{CMDSEGMENT:1}'

next step is:
When I say:
Quote
[Player 1;Player 2;Player 3;Player 4;Player 5; and so on until player 30] Defender do something

When this command executes, do the following sequence:
Begin Text Compare : [{CMDSEGMENT:0}] Equals [PlayerVariable]
    Press D key and hold for 0.15 seconds and release
    Pause 0.1 seconds
    Press S key and hold for 0.15 seconds and release
End Condition

What i wanted to accomplish is that only when the correct player number is used the command will be executed.
So far so good and everything works. Sometimes though only one player is available so there is no use to use "player X" in the command, so:

Quote
When I say:
Defender do something

I would like the key-press section of the resulting sequence to execute also. That would make "player x" an optional part of the command. First I thought just adding a semicolon behind "player 30" would do the trick, but of course that would be to easy  ;D

I think my problem should not be fixed in the command but in the resulting sequence but I can't figure out how to solve this, and wonder if it's even possible.
Any advice would be appreciated.

Greetings,
Richie

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Possible to make {CMDSEGMENT} variable optional?
« Reply #1 on: May 01, 2019, 10:54:55 AM »
When I say:
Set Player [Player 1;Player 2;Player 3;Player 4;Player 5; and so on until player 30]
Did you actually type out "Player " followed by a number 30 times?

You can use "Set Player Player [1..30]", and VoiceAttack will extrapolate the numbers for you(note that you'll want to use "{CMDSEGMENT:1}" instead, which will then only contain the number).


Quote
When I say:
Defender do something

I would like the key-press section of the resulting sequence to execute also. That would make "player x" an optional part of the command. First I thought just adding a semicolon behind "player 30" would do the trick

If you make that section optional by adding the semicolon, the token will return blank, so you'd want to add a check for that:
Code: [Select]
Begin Condition : [{CMDSEGMENT:0}] Equals [PlayerVariable] OR [{CMDSEGMENT:0}] Equals ''

Richie67

  • Guest
Re: Possible to make {CMDSEGMENT} variable optional?
« Reply #2 on: May 01, 2019, 01:29:40 PM »
Did you actually type out "Player " followed by a number 30 times?

 ;D ;D No I did not  ;D ;D , in fact in the profile 30 different names are used, the player 1 and so on in the question was just used as example

If you make that section optional by adding the semicolon, the token will return blank, so you'd want to add a check for that:
Code: [Select]
Begin Condition : [{CMDSEGMENT:0}] Equals [PlayerVariable] OR [{CMDSEGMENT:0}] Equals ''

Thanks for the suggestion,  I will try that as soon as possible