December 2, 2025Dec 2 I am attempting to create a toggle switch for a water injection feature on the Aeroplane heaven P-47. I suspect I will need to create a script. I searched other posts about scripting and found this: Make sure that AAO is connected to the sim and that you are sitting in the cockpit Open "Scripting->Script Editor" Copy and paste my code above into the big white box Use the "Test" button to see if it works Enter a "Title" for the script at the top and select a group, for example "Scripts". (you can create your own groups with the "Manage Script Groups" button. Press "Save as new" Open your button definition Delete the Key Up Open the Key Down selection, scroll down to the group that you've selected for the script, open the group, doubleclick on the title of your script So the problem I have remaining is what kind of syntax/structure I need to include in my script. I have never built a script before. The event I am using is INSTRUMENT_SWITCH_Waterinjection_Set Can someone offer a suggestion as to what my script for a toggle (1st press water injection ON, 2nd press water injection OFF) might look like? Many thanks in advance, Chris Edited December 2, 2025Dec 2 by Chris455
December 2, 2025Dec 2 Commercial Member 24 minutes ago, Chris455 said: INSTRUMENT_SWITCH_Waterinjection_Set What is that? LVar, BVar, IE - ??? The type is missing, and without it, this string tells us nothing. First thing to learn is proper syntax concerning variables and events. Otherwise all attempts at scripting will end in pain. The AAO manual has an extensive chapter about Scripting, and there is a small introduction in the MSFS SDK documentation too. Reverse Polish Notation Edited December 2, 2025Dec 2 by Lorby_SI LORBY-SI
December 2, 2025Dec 2 Commercial Member 9 minutes ago, Chris455 said: So sorry, It is an IE- Can I make a script from an IE? You can make scripts with anything. For a toggle you will have to find out how to read the value of the IE. In my experience it is better to use it as a BVar instead (IEs can be written either way) Assuming that the value range is exactly 0 and 1, then the toggle script would look like this 1 (B:INSTRUMENT_SWITCH_Waterinjection) - (>B:INSTRUMENT_SWITCH_Waterinjection_Set) "Read the value of the BVar and subtract it from 1, then write the result back into the BVar" This will make the var alternate between 0 and 1 every time the script is called. Since I don't have that aircraft I cannot know if my script is correct or comment on how to do this with the IE itself. IEs are always aircraft specific, and I have no way of knowing how to get the value of that IE. Only you can do that in MSFS's developer mode or in AAO with the tools in the "Scripting" menu. Here are some alternatives: 1 (IE:INSTRUMENT_SWITCH_Waterinjection_Set) - (>IE:INSTRUMENT_SWITCH_Waterinjection_Set) or 1 (B:INSTRUMENT_SWITCH_Waterinjection_Set) - (>B:INSTRUMENT_SWITCH_Waterinjection_Set_Set) or try assigning B:INSTRUMENT_SWITCH_Waterinjection_Set_Toggle or B:INSTRUMENT_SWITCH_Waterinjection_Toggle directly to your button. When you open an IE in the event list you will find the BVars attached as sub-nodes Edited December 2, 2025Dec 2 by Lorby_SI LORBY-SI
December 2, 2025Dec 2 Author B:INSTRUMENT_SWITCH_Waterinjection_Set_Toggle - this did the trick, Thank you!
December 3, 2025Dec 3 To toggle a variable from 1 to 0 or 0 to 1 this operation works well: (V:TheVariable) ! (>V:TheVariable) This basically reads the variable then flips its binary value and writes it back to the same variable Edited December 3, 2025Dec 3 by mrm0508 | i7-14700KF - 4080 SUPER | 32 GB RAM | Win 11 Pro | HC Bravo | AAO | StreamDeck |
Create an account or sign in to comment