Author Topic: MWO Nightvision+Thermal Toggles  (Read 8840 times)

mikeycantoon

  • Guest
MWO Nightvision+Thermal Toggles
« on: August 29, 2016, 06:13:11 PM »
Okay.  I've gotten voice attack to work just fine with MWO.  It's easy enough to bind the N key to (Nightvision;Nightvision on;nightvision off) to toggle it on and off.  Same with Thermal using the H Key.  As you see I have to repeat or add words to that keybind to toggle it on and off, which still, does work fine. 
BUT.  I'd like to have separate sayings and for the program to know if thermal\nightvision is on or off, and if it's on and you say "Nightvision on" it will tell you it's already on, whereas "Nightvision" off would turn it off if it was already on.  Mainly.  I want to add a command Normal Vision Mode to restore normal vision mode if it's in either thermal or nightvision.
I copied an integer setup from someone who used it on Elite dangerous and tweaked it for MWO.  If I say "toggle Nightvision", it will toggle on and off.  But saying "Nightvision on" shows up as a recognized successful command but does not turn on nightvision, neither does saying "nightvision off".  So I believe that my keybinding and toggle is setup correctly but the seperate commands for "Nightvision on" and "Nightvision off" have no effect.  This could be that the software can't see if it's on or off.  I'm not sure and so I'm just looking to see if what is wrong in what way or voice-attack simply can't see if nightvision/thermal is on or off making the the code I used useless.

So here it is:  Nightvision;Nightvision on; - Supposed to Turn night vision on.  Doesn't work.
                     Nightvision off; - Supposed to turn night vision off.  Doesn't work.
                     Toggle Nightvision - Does turn it on an off

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: MWO Nightvision+Thermal Toggles
« Reply #1 on: August 29, 2016, 07:20:24 PM »
This could be that the software can't see if it's on or off.  I'm not sure and so I'm just looking to see if what is wrong in what way or voice-attack simply can't see if nightvision/thermal is on or off making the the code I used useless.
If you're implying that VoiceAttack can in some way tell whether night vision is on or not within the game, then no, it cannot.

mikeycantoon

  • Guest
Re: MWO Nightvision+Thermal Toggles
« Reply #2 on: August 29, 2016, 08:43:05 PM »
Okay.  Is there a way to set a variable in voice attack manually with a default of "Off" that another command can read from, enabling the toggle to function?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: MWO Nightvision+Thermal Toggles
« Reply #3 on: August 29, 2016, 09:32:04 PM »
Is there a way to set a variable in voice attack manually with a default of "Off"
I'm not sure what you mean by "with a default of "Off""; You initialize a variable with whatever the desired value is.

I recommend against using uninitialized variables in VoiceAttack. While you can do it, the default value of "Not Set" has some weird effects in evaluations("Not Set" will not make "Does Not Equal True" return "True").

that another command can read from
Every command can read every variable, they're all global. Keep this in mind when you're naming them.

mikeycantoon

  • Guest
Re: MWO Nightvision+Thermal Toggles
« Reply #4 on: August 29, 2016, 09:42:49 PM »
Is there a way to set a variable in voice attack manually with a default of "Off"
I'm not sure what you mean by "with a default of "Off""; You initialize a variable with whatever the desired value is.

Let me see if I can explain it this way.  Since voice attack doesn't know the default state of "nightvision" which is off by default right?  So if you were to say "nightvision off" it would tell you it was already off (if you had the sound file to say this) because the default state is already 0, off.  But say "nightvision on" and it see's the default state of 0, and turns to 1, on.  Could the default state be set manually for the toggle to work from.

Also, is my code completely wrong or what?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: MWO Nightvision+Thermal Toggles
« Reply #5 on: August 29, 2016, 09:55:45 PM »
Could the default state be set manually for the toggle to work from.
It can, and you should. Because of the way your commands work, you'll have to run the following before using them the first time:
Code: [Select]
Set small int (condition) [NIGHTVISION] value to 0You could add this to a command the executes whenever the profile is loaded.

If you foresee reloading the profile while the game is in progress:
Code: [Select]
Begin Small Integer Compare : [NIGHTVISION] Has Not Been Set
    Set small int (condition) [NIGHTVISION] value to 0
End Condition
This way reloading the profile won't reset the variable.

Also, is my code completely wrong or what?
There is no "wrong" if it works, which it will if you you initialize the variable.

mikeycantoon

  • Guest
Re: MWO Nightvision+Thermal Toggles
« Reply #6 on: August 29, 2016, 10:32:04 PM »
Dude!  Thank you!  I set a voice command "Reset" in my MWO profile to set that
Code: [Select]
Set small int (condition) [NIGHTVISION] value to 0I didn't have to change anything else.  I just had to say "Reset" and then the toggle worked perfectly with the appropriate commands.  Now if I can figure out how to run this command from the start of loading the profile maybe....  I'm an IT guy, but not a programmer, the other side of the fence, but was okay with programming but it's been 10yrs since I've looked at anything so I only have my basic knowledge of IF THEN statements in my head and it was hard for me to convey what I was wanting to accomplish.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: MWO Nightvision+Thermal Toggles
« Reply #7 on: August 29, 2016, 10:39:57 PM »
I set a voice command "Reset" in my MWO profile to set that
Code: [Select]
Set small int (condition) [NIGHTVISION] value to 0I didn't have to change anything else.
The reason your commands weren't working is that they check explicitly for a value of either "1" or "0". An initialized variable has a value of "Not Set", which is neither of those.

Chances are the profile you copied the actions from did set the variable at some point.

how to run this command from the start of loading the profile

Open the "Edit a Profile" window, click the checkmark next to the profile name to open the "Profile Options". Under the "Profile General Tab", you have the "Execute a command each time this profile is loaded" option.

mikeycantoon

  • Guest
Re: MWO Nightvision+Thermal Toggles
« Reply #8 on: August 29, 2016, 10:58:58 PM »
And that's it!  Awesome.  All working perfectly now.  Thanks for all your help.  I searched youtube and google but couldn't quite find what I was looking for compounded by me not knowing exactly how to search for the answer either.  This helps me in not just MWO but better understand the Voice-Attack software better for other games and applications.  I just kept asking myself, how does it know the default state to run against??  But I couldn't word it so simply. 
I've been at it since yesterday and I'm really happy to have got it resolved before bed tonight, feeling accomplished.  Thanks!