Author Topic: button1 toggle 2 different sounds  (Read 993 times)

lazerwolf

  • Newbie
  • *
  • Posts: 1
button1 toggle 2 different sounds
« on: October 19, 2020, 12:34:54 AM »
Greetings! I'm having a hard time figuring something out.
I just got my shiny new Virpil HOTAS with shiny candy like buttons that I want to press instead of using voice commands but I still want sounds triggered. Example:  In SC for lights on/off it's it's the button "L". Same button for both functions. Say I want to press button1 for lights on then trigger "lights_on.mp3" then when I press it again have it trigger "lights_off.mp3". As it stands now, when I press button1 both sounds play at the same time which is logical. I need to be able to set some sort of state and trigger this or that based on an integer I'm guessing. Something like: press button1 (add 1 to integer) if value =1 then play lights_on.mp3 only. Press button1 a second time (add 1 to integer) if value =2 then play Lights_off.mp3 only, then reset integer. I'm failing to make this work. Does anyone know how to? Thanks!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: button1 toggle 2 different sounds
« Reply #1 on: October 19, 2020, 12:42:02 AM »
If you're keeping track of a binary state (I.E. one of two possible states), you can use a Boolean variable, E.G.
Code: [Select]
Begin Boolean Compare : [lightsOn] Equals False
    Play sound, '{VA_SOUNDS}\lights_on.mp3'
Else
    Play sound, '{VA_SOUNDS}\lights_off.mp3'
End Condition
Set Boolean [lightsOn] to Toggle

Make sure to enable the "Evaluate 'Not Set' as false" option for the "Begin a Conditional (If Statement) Block" and "Set a True/False (Boolean) Value" actions.