Author Topic: make VA give different answers when the same joystick button is pressed  (Read 846 times)

Jan27!

  • Newbie
  • *
  • Posts: 12
Hello,

I'm very new to this great software. I managed to make checklist for DCS A10C and for the F18 Hornet. But I did this with no understanding in what I was doing. Just copied the trick from somebody else:
https://prosim-ar.com/forum/viewtopic.php?t=14038

But I want to try something myself. I read the manual (but got lost in it), read all the posts of this forum, but still not get the logic. Not a big deal because I am not a programmer. But I want to learn Voice Attack. So I've two questions:

1. In DCS I can select four weapon types (guns, AMRAAM, Sparrow and sidewinder) with four different joystick knobs. With one of them selected, I can push (at any time) the joystick trigger and that will release the selected weapon. Then I want VA to say " Fox two" or "Fox one" or "guns, guns, guns" or "Fox Three", just depending on what kind of weapon was selected. And that is the problem. I've tried to do this with a Else-If statement, but do not know where to begin? Prefix/Suffix?
Suggestions? Are there more then one solutions for this problem?

2. It's obvious that  some programming skills are required to understand the logic of Voice Attack. The Manual is of great help but not is sufficient for me. Do any of you have suggestions how to learn Voice attack with the help of youtube? websites? Simple books? Again: I know nothing about programming but want to learn much more of it, just because Voice Attack has so much potential.

But: Thanks again for this great program. I love my checklists and couldn't do without them!!!

Jan27!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: make VA give different answers when the same joystick button is pressed
« Reply #1 on: August 10, 2020, 09:40:37 AM »
For a command to act upon a given state, you need a variable value representing said state, and flow control actions to alter the execution of the command depending on the value of said variable.

E.G. if you have a command that sets your current weapon to "guns" (even if you have your joystick button set up ingame directly, you'll want to have it trigger a VoiceAttack command as well to keep track of state changes), it could contain something like
Code: [Select]
Set text [activeWeapon] to 'guns'

I'd use a text value rather than a magic number (E.G. an integer value where 1 means guns, 2 means AMRAAM, etc...) for readability.
Unless you're going to use a value to do math (including incrementing and decrementing it), that's generally what I'd recommend (the overhead isn't really relevant on a modern computer) in this context.


In the command that fires when you press the trigger button on your joystick, you'd then have something like
Code: [Select]
Begin Text Compare : [activeWeapon] Equals 'guns'
    Say, 'guns, guns, guns'
Else If Text Compare : [activeWeapon] Equals 'AMRAAM'
    Say, 'Fox three'
Else If Text Compare : [activeWeapon] Equals 'Sparrow'
    Say, 'Fox one'
Else If Text Compare : [activeWeapon] Equals 'Sidewinder'
    Say, 'Fox two'
Else
    Say, 'No active weapon'
End Condition

The "Else" action's branch will be executed if the variable has a value other than the four listed, which would occur if no value has been set yet (I.E. when you press the trigger before pressing a button to select a weapon)



Neither of these concepts are specific to VoiceAttack; This topic attempts to explain the basic control flow involved, with VoiceAttack actions as examples.

General guides on the basic principles of programming should also explain these concepts (while the syntax will differ, the underlying logic is the same).
VoiceAttack is written in C#, and as such the GUI-based scripting system has many commonalities with that language, including being strongly typed (basically meaning variables can only store their specific kind of data, E.G. an Integer variable cannot hold text)

Jan27!

  • Newbie
  • *
  • Posts: 12
Re: make VA give different answers when the same joystick button is pressed
« Reply #2 on: August 10, 2020, 01:28:27 PM »
Hello, Thank you for your very fast reply. I now do understand the logic, so with that in mind I tried to put this code in the Interface of Voice attack. Well, with some trial and error..... yes, it worked!!!!

Thanks for your quick response

Jan27!

 
 
« Last Edit: August 10, 2020, 02:59:05 PM by Jan27! »