In a thread in the WOP2 section I described how to provide keyboard/button control to Accusim and other commands that cannot be assigned via normal FSX means.viewtopic.php?f=55&t=19524
Basically that thread provides a Macro file with 'new' commands in and explains how to operate them. By using this Macro file with a program called FSUIPC you can operate commands not normally available through the standard FSX interface. Put it this way, I added an extra 37 controls to the P47 accusim, and probabaly missed a few!
In that thread I promised to provide an explanation on how I produced the Macro file and I was asked today to produce a Macro file by another member for the B377, a plane I do not have. So I have decided instead to produce the explanation here of how to make a Macro file yourself! Note I have provided a Macro file for the WOP2 P40 and P51 and well as for the accusim system for the P47, though there is no reason why these cannot be improved.
First and foremost: You need a registered
copy of a program called FSUIPC 4. (get googling, about 24 euros I think. Worth double the money!!). I have used version 4.53 and cannot say if this will work with earlier versions, however if you have a registered copy you can upgrade to the latest version. FSUIPC is one of the most useful utilities for FSX and allows you far
more control over FSX and controls than without. I have no hesitation in recommending this program....plus you need it anyway to both create and use Macro files!!
Second. I cant garuantee this 'system' will work with other A2A aircraft that I havent tried myself, however I see no reason why it should not work. I have so far used it on aircraft produced by other Add-on makers with varying degrees of success.
Third: This does not make any changes to your aircraft of FSX programs. Everything is done within the FSUIPC program (I believe so anyway....). Simply deleting the macro file will remove the controls from your system. However you still working at your own risk etc. etc.
Fourth: I am assuming the reader has a registered copy of FSUIPC and has some experience using it.STEP 1.
First go to your FSX files and find the 'Modules' folder and open this up. You will be doing most of the work within this folder. This folder is where FSUIPC lives and the files associated with it. In there you should find various PDF files which give explanations on how to use FSUIPC, they are thorough and very useful, in fact its basically where I learnt how to do this! I suggest you open up 'FSUIPC for advanced Users' and have a look at pages 30 & 34, also there is a PDF file about LUA plugins which is useful.STEP 2
within the 'Modules' folder you will find a folder called 'Example LUA Plugins'. Open that folder and find an icon called 'log lvars.lua'. Simply move this up a step into the 'Modules' folder (or copy and paste if you wish). If the .lua file is in 'Modules' the FSUIPC can see and therefore use it. LUAs are basically programs that run within FSUIPC and can do all sorts of things, in this case it will read LVars (local variables) when we press keys in the cockpit. For more info in LUAs read the manual!
Next start up FSX. You will be constantly jumping in and out of FSX so I recommend you use windows mode whilst tinkering (ALT-ENTER). go to free flight and start a flight with the aircraft you wish to produce controls for, I would suggest make it dark and cold...certainly dont be flying...for now!STEP 3.
Next, when in your plane in FSX, open up FSUIPC. The first thing we need to do is assign some controls for the LUA program we just moved. I suggest using two key presses you dont use for anything else (I use F3 and F4). Next using FSUIPC set a key for each of these two commands which you should find in the control list:
'Lua log Lvars' and 'LuaKillAll'
There are other controls associated with LUAs, however I only used these two.
Click ok in FSUIPC and return to your cockpit. Now, press the key assigned to 'Lua log Lvars' and you will see a panel with a lot
of red text come up, press the key for LuaKillAll and this should disappear(sometimes you need to press both a few times for it to work). If that works you can now read LVars within the cockpit! (this is the key to this whole system and how we can operate these controls, thanks Pete Dowson!!!! (the maker of FSUIPC))
Now start the LUA and then start flicking switches in the cockpit with your mouse, you should see all sorts of things come up in red text (it may be 'rolling' anyway as things like oxygen or hydraulic pressure deplete). Dont worry about trying to read these entries within FSX, there is an easier way!
After trying some controls stop the LUA and go to your 'Modules' folder. Now you should see a file called 'log.lvars.log'
Open this file using notepad and you will see all of the entries that appeared in red on your screen in FSX within this file. Every time you start the LUA in FSX, entries are added to this file, however you need to shut it down and start it again every time you do this wioth the last entires being at the bottom. The entries in this file are Lvars, or local variables and they cover all sorts of things, though their names generally give you an idea of what they do. What use are these things? well we are going to use these entries to create a Macro file.STEP 4.
Next we need to create a Macro file for the aircraft you are flying. Right click and start a new .txt file in notepad. Rename the file to 'whateveraircraft.MCRO' Place this file in the 'Modules' folder. For this explanation I will be using part of the Macro file I created for the P47. I called that file 1P47.MCRO. the reason I put a '1' at the start is so that it appears right at the beginning of the controls list in FSUIPC, so it is easier to find the individual controls once we start using the files itself. If you already have a macro starting with 1, use a different figure!
Next, open it in notepad and right at the top put a header of [Macros] This must
have the square brackets and be called [Macros] if it is anything else it will not work and FSUIPC will not see it! Here is an example of the first few lines of my 1P47.MCRO file
If you where to now assign keyboard/ joystick buttons or switches to the above commands as explained in the P47 thread you could operate the controls. So where did I get the controls from? Well im sure you have guessed, I got them from the 'log lvars.log' file! However they need some work before they can be used.
Here are the corresponding entries taken from within the 'Lua log Lvars'...you need to go searching!
123672 LUA: L:GunSightSwitchOn=1
125547 LUA: L:CabinVent=0
Th part in blue is the control, you can ignore the stuff before it. The part in red is the parameter. This will change dependant upon the switch position and its function...you will be expermenting with these a lot! I simply copy the blue part and paste it into my Macro file after the 'number'=
So, to create the macro file you need to have a look through the Lvars log and find likely looking names of Lvars. Through experimentation you should be able to find you what they do and use some of them to create you macro file.
What I do is this: within the Macro file, each entry has a number followed by the '=' sign. This is shown in green in my example above, also have a look at my P47 macro file in the other thread (link at top of this thread). These need to be sequential as these identify to FSUIPC and FSX the control, though you can have missing numbers (and after much experimenting, you will do!) as you delete/ change entires. After the '1=' is the blue part of the entry from the Lvar log, i.e. from L:XXXXX=
After the'=' at the end you need to add either SET or TOG.SET and TOG
SET or TOG (short for Toggle) tell FSUIPC how to operate this switch. With the SET command you will need to set a parameter (i.e. the red part of the Lvar log example above) for each control. I have explained fully how to do this in the P47 thread. I use SET because my home made controls use actual switches which stay on or off permanently. However if you are using either a keyboard or spring loaded joystick buttons you should probably use TOG. this simpl changes the state of the control every time you press the button or key. Basically, expermiment with these ands you will se how they operate.Parameters
Here is where the fun starts! What ar the parameters? basically most controls which are a simple on/off switch such as the gunsight control have two states, on and off. In most cases a parameter of =0 equates to 'of' and =1 equates to 'on' as is the case with the Gunsight switch.
Some controls have 3 positions (such as the P47 starter control or landing light swicth) and these may have parameters of 0,1 and 2. SOme controls have other parameters, e.g. the cabin vent control gradually opens the cabin vent and has paramters from =0 for closed to =100 for fully open, with 1-99 for intermediate positions. The only way yo find out the parameters is to experiment. Start the log running in FSX, flick the switches then investigate the the LVar log file.STEP 5
SO, you have created a Macro file with a few entries (I suggest just a few at first till you get the hang of it all), what next? Save the macro file and go back to FSX. Open up FSUIPC and go to the sections for assigning either a key or button press. Next is it vital
that you click 'reload keypresses' or 'reload buttons' as appropriate. As im sure you can guess this reloads the buttons. This handy feature also means that you can edit the Macro file as much as you like whilst FSX is running (a godsend!), so long as you click 'reload keypresses' every time you do (after saving the macro file off course).
Next assign a key or button to the new controls. These new controls should appear in the list dependant upon the macro filename (this is where you now go and put a 1 at the front!!), howver please note: within the macro list in FSUIPC the controls appear in alphabetical order rather than the order they appear in the macro file itself. Click ok, go back into your cockpit and press you key or button.....this is the moment of truth...did the control work?!?! Well sometimes it will and sometimes it wont! This is where the experimentation comes in. After a while you get a feel for it. Try different parameters and different Lvars.
After you have tried a few, start the LUA program again and flick a few more buttons. Open up the Lvars log file in you module folder and select a few more controls and add them to your macro, save it, go back into FSX, open FSUIPC, reload the buttons and then assign keypresses to your new controls. Repeat for several hours or until you brain goes numb!
There may be times when you need to assign two or more macros to a single key or button. See the part about the Turbo Clutch control in my P47 thread for an explanation (linky at start of this thread)
The key to this is experimentation. As I dont have other aircraft (yet!) I cant say what will and wont work...just play about and see what you can do!, oh and enjoy!!! My P47 thread explains in much more detail how to assign controls to the entries within the Macro file.Hints and Tips
1. Remember to close down and restart the 'log lvars.log' file after every time you have run the LUA within FSX
2. The Macro file must be called XXX.MCRO and the first entry must
be [Macros] if not, FSUIPC wont see it!
3. Make sure the numbering is correct within the macro file. You can have missing numbers but not two controls with the saem number.
4. End each control with either =SET ot =TOG. if you use =SET you must assign a parameter...experiment!
5. Save the macro file after every change
6. Reload all buttons or keys within FSUIPC after each edit of the macro file
7. try a few controls at a time, perhaps sticking to single panels
8. This does not find normal FSX commands, or the extra FSX commands that you can normally access through FSUIPC, it only seems to find 'extras' (dont quote me on that though!)
9. Experiment! you cant break it.....at least I dont think you can!
10. The Find function is notepad is very useful......