Author Topic: Same key press but only one command should me done  (Read 2710 times)

DetlefP

  • Guest
Same key press but only one command should me done
« on: April 30, 2017, 05:33:15 AM »
I came across a new, probably simple, Problem.

I have assigned a key to lights on/off in my game. It works perfect with spoken commands and it even know when the light is already on and gives an error message so it wont turn the lights again on when i say on...

So my problem is that on and off is of course on the same key, lets say "L".
So, when i actually press the key, both commands will be executed. i am trying to make a simple routine that VA knows if i press "L" it only can turn the light on when they are off. any ideas?
I know i need to use some type of key check command to set any values before it can continue.





iceblast

  • Sr. Member
  • ****
  • Posts: 374
Re: Same key press but only one command should me done
« Reply #1 on: April 30, 2017, 06:54:47 AM »
I don't know if this will help, but I'll throw it out there.

Did you check, "Do not allow key to be passed through."

Just figuring, if the command works fine with voice, but when you hit the key it doesn't, you could be triggering it twice if you didn't check that box.

DetlefP

  • Guest
Re: Same key press but only one command should me done
« Reply #2 on: April 30, 2017, 08:41:44 AM »
Has no Effect. It still does light on and off at the same time. Sometimes first the On and other times the Off first.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4778
  • RTFM
Re: Same key press but only one command should me done
« Reply #3 on: April 30, 2017, 10:16:53 AM »
Show us the actions lists of the commands you already have.

DetlefP

  • Guest
Re: Same key press but only one command should me done
« Reply #4 on: April 30, 2017, 10:25:51 AM »
This is for light on:
Code: [Select]
Begin Small Integer Compare : [ship.lightpossible] Equals 0
    Play sound, '{VA_SOUNDS}\Elite Dangerous\Sperrung\gesperrt.mp3'
End Condition - Exit when condition met
Begin Small Integer Compare : [ship.light] Equals 1
    Play sound, '{VA_SOUNDS}\Elite Dangerous\Beleuchtung\leuchtschonan.mp3'
End Condition - Exit when condition met
Press Insert key and hold for 0,1 seconds and release
Play random sound (5 items)
Set small int (condition) [ship.light] value to 1
Set small int (condition) [ship.lightpossible] value to 1

this is for lights off:
Code: [Select]
Begin Small Integer Compare : [ship.light] Equals 0
    Play sound, '{VA_SOUNDS}\Elite Dangerous\Beleuchtung\leuchtschonaus.mp3'
    Set small int (condition) [ship.lightpossible] value to 1
End Condition - Exit when condition met
Press Insert key and hold for 0,1 seconds and release
Play random sound (5 items)
Set small int (condition) [ship.light] value to 0
Set small int (condition) [ship.lightpossible] value to 1

iceblast

  • Sr. Member
  • ****
  • Posts: 374
Re: Same key press but only one command should me done
« Reply #5 on: April 30, 2017, 11:13:45 AM »
Is the On and Off commands part of just one command? Or do you have them in 2 separate commands?

You're controlling what mp3 will play, and having the Insert button hit everytime, for both commands, if they are in the same command, that's why you're double tapping.

Otherwise, not sure, both commands singularly wouldn't double tap the light switch. Unless you have it set to run twice at the bottom of the command, or if your letting the key pass through, or there is another command being activated somewhere else in your profile.

I don't know, Pfeil is better at this then me, so, maybe he'll see something I don't.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4778
  • RTFM
Re: Same key press but only one command should me done
« Reply #6 on: April 30, 2017, 11:43:10 AM »
I'd recommend putting your actions into a single command:
lights [on;off]
Code: [Select]
Begin Boolean Compare : [ship.light] Equals False
    Begin Condition : ([{CMDACTION}] Equals 'Spoken' AND [{CMD}] Contains 'off')
        Play sound, '{VA_SOUNDS}\Elite Dangerous\Beleuchtung\leuchtschonaus.mp3'
    Else If Boolean Compare : [ship.lightpossible] Equals False
        Play sound, '{VA_SOUNDS}\Elite Dangerous\Sperrung\gesperrt.mp3'
    End Condition - Exit when condition met
    Press Insert key and hold for 0,06 seconds and release
    Play random sound (5 items)
    Set Boolean [ship.light] to True
    Set Boolean [ship.lightpossible] to True
Else
    Begin Condition : ([{CMDACTION}] Equals 'Spoken' AND [{CMD}] Contains 'on')
        Play sound, '{VA_SOUNDS}\Elite Dangerous\Beleuchtung\leuchtschonan.mp3'
    End Condition - Exit when condition met
    Press Insert key and hold for 0,06 seconds and release
    Play random sound (5 items)
    Set Boolean [ship.light] to False
    Set Boolean [ship.lightpossible] to True
End Condition
This command requires VoiceAttack v1.6.4.1 or newer as it uses the condition builder feature.

Both condition builder conditions contain two "Text" compares, where the token(in "{}") goes in the "Variable Name / Token" field, and the text it's compared against goes into the "Text" field.

This allows you to either speak "light on" or "light off", which work as your current commands do, or any other method of triggering the command(keyboard key, mouse button, joystick button, or executing it from the command list context menu) to toggle between both states.


Note that I've used "Boolean" rather than "Small Integer" values for "ship.light" and "ship.lightpossible"; A boolean value is either "True"(for on, in this case), or "False"(for off, in this case).
It'll work fine with small integer values as well, but as you're using it to keep track of a binary state, the boolean datatype is the right tool for the job.

If you're going to use boolean values in this context, do make sure to check the "Evaluate 'Not Set' as false" option in conditions that use it.