Results 1 to 1 of 1
-
06-29-2018, 12:24 PM #1
- Join Date
- Oct 2008
- Location
- Milwaukee, WI
- Posts
- 55
A Quick Guide: Hardware Switches, FSUIPC, Lua, and 3rd-Party Aircraft, and FSX
Hello cockpit builders,
I am working on a Vulcan simulator. I am looking forward, with great anticipation, to the JustFlight Vulcan (https://www.justflight.com/product/avro-vulcan-b-mk2). But, I've never interfaced hardware switches with 3rd-party aircraft, so I am including my steps, here, for those who wish to do the same:
------------------------------------------
************************************************************************
TO PROGRAM A HARDWARE SWITCH WITH A 3RD-PARTY AIRCRAFT WITH FSX
************************************************************************
**** INSTALL THE XML VARS INSTRUMENT
1) At https://www.douglassdawson.ca is a ZIP file, xml_vars.zip.
2) UnZIP it, and get its xml_vars.gau and xml_vars.txt files. Put them in Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Gauges (or whatever your path to Microsoft Flight Simulator X is).
3) In Notepad, open the xml_vars.txt file, and copy the contents of xml_vars.txt to the clipboard.
4) In Windows Explorer, navigate to <FSX path>\SimObjects\Airplanes\<aircraftName>\panel, and edit Panel.cfg.
NOTE: You might need to first copy the Panel.cfg somewhere else, like C:\Temp (or whatever location on your hard drive) to edit it, and then copy it back to the \panel folder. This is because Windows Permissions might prevent you from editing the Panel.cfg file in its original folder.
5) In Notepad, open the Panel.cfg file. Scroll through the file, to locate the last [WindowXX] section, and paste-in the contents, under the last [WindowXX] section (where XX is a number like "03"), and modify the [WindowXX] number of your pasted-in text to be one number higher. For instance, if the last entry was [Window03], you will modify your pasted-in content to be [Window04].
6) Edit the [Window Titles] section at the top, and add the following to the list of other Window Titles: WindowXX=LVars (again, this will be Windows 04=LVars, or whatever the number is for your pasted-in text).
7) Save the Panel.cfg file, and copy it back to the <FSX path>\SimObjects\Airplanes\<aircraftName>\panel folder.
**** START THE AIRCRAFT AND VIEW THE VARIABLES
1) Open the 3rd-party aircraft in FSX.
2) Choose Views > Instrument Panel > LVars. You'll see the LVars "instrument" appear at the top left, and can size it using the sizing handles at its edges.
3) Click on the center of the LVars "instrument" to scroll through it -- note the list of LVars Names. These correspond to the various switches found in your 3rd-party aircraft's instrument panels.
4) Find the Name of the switch in the aircraft cockpit, click the switch in the aircraft cockpit with your mouse, and note the Name and the Dec Value with each click. For instance, you'll see the Dec Value for the given switch you are clicking go from 0 to 1 to 0 to 1, etc., each time you click the switch with your mouse. This Name (i.e., the LVar Name) and Dec Value will be used, below.
**** CREATE A LUA FILE
1) Make a text file using Notepad, and copy-and-paste the following (in this example, "vc10_ohp_col1_turnoff_left" is the LVar Name, and it has two values, 1 for switch on, and 0 for switch off.
function VC10_OHP_Col1_Turnoff_Left_On ()
ipc.writeLvar("vc10_ohp_col1_turnoff_left", 1)
end
function VC10_OHP_Col1_Turnoff_Left_Off ()
ipc.writeLvar("vc10_ohp_col1_turnoff_left", 0)
end
function VC10_OHP_Col1_Turnoff_Left_Toggle ()
if ipc.readLvar("vc10_ohp_col1_turnoff_left") == 0 then
VC10_OHP_Col1_Turnoff_Left_On ()
else
VC10_OHP_Col1_Turnoff_Left_Off ()
end
end
VC10_OHP_Col1_Turnoff_Left_Toggle ()
2) Replace the above content, such that VC10_OHP_Col1_Turnoff_Left_On, VC10_OHP_Col1_Turnoff_Left_Off, andVC10_OHP_Col1_Turnoff_Left_Toggle are any Function names that you want (for explanations on Lua Functions, do a Google search). Just be sure to change all of them. Replace vc10_ohp_col1_turnoff_left with the LVar Name that you noted from above, and replace the 1 and 0 with the Dec Value from above.
NOTE: What the code, above, does is: 1) Declares a function that will turn the LVar variable On, 2) declares a function that will turn the Lvar variable Off, 3) declares a function that checks the current state of the Lvar variable and turns it On or Off, and 4) launches, or calls, the 3rd function. If you look through the contents carefully, it will make more sense.
3) Save the file as something like vc10_turnoff_lt.lua, and save it in <FSX path>\Modules folder (I think the file name must be less than 16 characters).
**** PROGRAM FSUIPC
1) With the hardware device connected (i.e., a joystick, etc.) in FSX, choose Add-ons > FSUIPC from the menu at the top.
2) Click the Buttons And Switches tab.
3) On your hardware device (i.e., your joystick), click the hardware button.
4) Put a checkmark in "Select for FS control".
5) Scroll through the list, to find the listing, "Lua Vc10_turnnoff_lt".
6) Click OK, to minimize FSUIPC.
6) Un-Pause FSX, and click the hardware button (i.e., on your joystick). In the 3rd-party aircraft, the switch on the instrument panel should now cycle from On to Off, with each click.
Meet Women Ready for Fun Tonight in Your Town
Experience the Best of Casual...