Dirk98 Posted March 26, 2013 Report Share Posted March 26, 2013 Hello, Is it possible to combine somehow 2 Lvar controls in one lua file? For example, I have one lua file to toggle FD and another lua to toggle ATHR in Airabus X Extended: AXE_FD.lua FD = ipc.readLvar("L:AB_MPL_FD") if(FD == 1) then ipc.writeLvar("L:AB_MPL_FD", 0) else ipc.writeLvar("L:AB_MPL_FD", 1) end ipc.writeLvar("L:SmallOverheadPushButtons", 1) AXE_ATHR.lua AXE_ATHR ATHR = ipc.readLvar("L:AB_AP_ATHR", 1) if(ATHR == 1) then ipc.writeLvar("L:AB_AP_ATHR", 0) else ipc.writeLvar("L:AB_AP_ATHR", 1) end ipc.writeLvar("L:SmallOverheadPushButtons", 1) If I map all my goflight pushbuttons and rotaries to AXE functions I'll end up with dozens of separate lua files in Modules folder. Is it possible to make it more compact, for example, combine Lvars into one file, or drop all LUAs in a folder and show the path to it in FSUIPC.ini etc? Thanks, Dirk. Link to comment Share on other sites More sharing options...
aua668 Posted March 27, 2013 Report Share Posted March 27, 2013 Hi, Write your small pieces of LUA code as functions in one single LUA file and register events for the GoFlight buttons in tha script triggering the correct function. Have a look in the LUA library for examples. That works perfectly. Rgds Reinhard Link to comment Share on other sites More sharing options...
Dirk98 Posted March 27, 2013 Author Report Share Posted March 27, 2013 Hi, Write your small pieces of LUA code as functions in one single LUA file and register events for the GoFlight buttons in tha script triggering the correct function. Have a look in the LUA library for examples. That works perfectly. Rgds Reinhard Reinhard, what works better performance wise in general? Many small lua files corresponding to each function, or one big lua file with all the pieces of separate LUA codes? The part of registering events for the GoFlight buttons is obvious, but how about enumeration of small pieces of code in one list? What is the format or better an example? Thanks, Dirk. Link to comment Share on other sites More sharing options...
aua668 Posted March 27, 2013 Report Share Posted March 27, 2013 Hi, You are limited in the overall number of LUA files you can use (limit was 128 - not sure if this has changed in the meanwhile). Therefore it's always better to combine these things and have fewer LUA files. And in terms of performance I would assume, that the difference isn't that big. But this is a question for Pete. If you have the functions in one LUA, you also can share variables, if you have global settings for example. Otherwise you have to work with LVars to share information across functions. So I would suggest to go for the proposed method. Rgds Reinhard Link to comment Share on other sites More sharing options...
Dirk98 Posted March 27, 2013 Author Report Share Posted March 27, 2013 Hi, Write your small pieces of LUA code as functions in one single LUA file and register events for the GoFlight buttons in tha script triggering the correct function. Have a look in the LUA library for examples. That works perfectly. Rgds Reinhard Reinhard, I'm trying to follow your advice to combine 2 different LUA files into one, based on 2 examples of LUAs I posted above. Please advise what is missing after the merge: FD = ipc.readLvar("L:AB_MPL_FD")if(FD == 1) then ipc.writeLvar("L:AB_MPL_FD", 0) else ipc.writeLvar("L:AB_MPL_FD", 1) end ipc.writeLvar("L:SmallOverheadPushButtons", 1) ATHR = ipc.readLvar("L:AB_AP_ATHR", 1) if(ATHR == 1) then ipc.writeLvar("L:AB_AP_ATHR", 0) else ipc.writeLvar("L:AB_AP_ATHR", 1) end ipc.writeLvar("L:SmallOverheadPushButtons", 1) Lol, I can imagine there should be some ref. enumeration of the functions first, so could you please add the necessary lines? Much thanks, Dirk. Link to comment Share on other sites More sharing options...
aua668 Posted March 28, 2013 Report Share Posted March 28, 2013 Hi, My code would look like this: -- toggle FD buttonfunction toggleFD (joynum, button, downup) ipc.writeLvar( "L:AB_MPL_FD", 1 - ipc.readLvar("L:AB_MPL_FD") ) ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- toggle ATHR buttonfunction toggleATHR (joynum, button, downup) ipc.writeLvar( "L:AB_AP_ATHR", 1 - ipc.readLvar("L:AB_AP_ATHR") ) ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- register the buttons of your joystick triggering the functions-- replace joyletter by the actual used letter/number, also replace buttonX by the actual valueevent.button("joyletter", button1, 1, "toggleFD")event.button("joyletter", button2, 1, "toggleATHR")[/CODE]For details look in the LUA library reference document.RgdsReinhard Link to comment Share on other sites More sharing options...
aua668 Posted March 28, 2013 Report Share Posted March 28, 2013 Hi, And to be sure, that you get it running: Start this script automatically (e.g. via ipcready.lua or by some AUTO entry in the FSUIPC.INI according to documentation. This script must be run only once and is then sitting an waiting for the button events. Rgds Reinhard Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 -- toggle FD buttonfunction toggleFD (joynum, button, downup)ipc.writeLvar( "L:AB_MPL_FD", 1 - ipc.readLvar("L:AB_MPL_FD") )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- toggle ATHR buttonfunction toggleATHR (joynum, button, downup)ipc.writeLvar( "L:AB_AP_ATHR", 1 - ipc.readLvar("L:AB_AP_ATHR") )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- register the buttons of your joystick triggering the functions-- replace joyletter by the actual used letter/number, also replace buttonX by the actual valueevent.button("joyletter", button1, 1, "toggleFD")event.button("joyletter", button2, 1, "toggleATHR")[/CODE]RgdsReinhardVery interesting. I ended up for the same with this code:[CODE]-- F/D button toggleif ipcPARAM == 62 thenLVarSet = "L:AB_MPL_FD"val = 0if ipc.readLvar(LVarSet) == 0 thenval = 1endipc.writeLvar(LVarSet, val)ipc.writeLvar("L:SmallOverheadPushButtons", 1)end-- ATHR button toggleif ipcPARAM == 9 thenLVarSet = "L:AB_AP_ATHR"val = 0if ipc.readLvar(LVarSet) == 0 thenval = 1endipc.writeLvar(LVarSet, val)ipc.writeLvar("L:SmallOverheadPushButtons", 1)end[/CODE]So in FSUIPC interface I just have to select the corresponding lua item and add parameters 62 and 9 where necessary.I used script v1.2 by guenseli, I understood how it works and then I added and modified more code based on the latest AXE SDK by Aerosoft, for example its V/S logic.However I'm interested in your method as well. "joynum, button" look clear, I think I know what to put in those fields, for example: J#3.B#12" But how do I edit "downup" field? (I'm talking about editing the code, not selectiing items in FSUIPC interface).Thanks,Sabre. Link to comment Share on other sites More sharing options...
aua668 Posted March 28, 2013 Report Share Posted March 28, 2013 Hi, If you combine a lot of such functions in one LUA file, which you then trigger by several buttons just by changing the paramater, you will run into a problem, if you have some more time consuming statements included in several branches. Why? You will find in the documentation, that with every starting of a LUA script, all potential current running instances of the same script are killed immediately. So imagine you must for example wait in one of your script until the panel is reacting, before you trigger the next action. And if the user presses another key during the previous script is running, you might get unwanted results. When I started to implement some LUA scripts for buttons I first came also to your solution. But believe me, the event driven version is much better. Because the several events can be fired quite quickly without disturbing each other. And by utilizing the visibility of variables you can define global things for all functions. Maybe you check the LUA concepts at http://www.lua.org/manual/5.2/ And by defining the logic in the LUA file with events, you nothing have to define anything in the buttons section. This might be helpful if you add planes and want to reuse the code. So don't forget to delete the assignments you made for the buttons, as they are handled by the LUA startet once when the simulator is ready. Rgds Reinhard Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 Reinhard, maybe you can figure this out: In AXE SDK among others there are 3 specific LVars for V/S - FPA knob, that are: AB_AP_VS_Select2 AB_AP_HDGTRK AB_AP_FPA_Select2 HDGTRK button switches mode between VS_Select2 and FPA_Select2 modes. I'm not sure if this can somehow be merged so that one V/S hardware wheel (or knob) could understand and control both VS or FPA, depending on the mode changed by HDGTRK button. What I mean is that now I can only map my hardware VS wheel either to VS_Select2 or FPA_Select2. Obviously pressing HDGTRK button immediately loses control of the currently mapped function (VS_Select2 or FPA_Select2 depending on the script used). So, how to make the script explain and hand over control of the next function (VS or FPA code) to my hardware wheel each time HDGTRK is pressed? Thanks. Dirk. Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 Hi, If you combine a lot of such functions in one LUA file, which you then trigger by several buttons just by changing the paramater, you will run into a problem, if you have some more time consuming statements included in several branches. Why? You will find in the documentation, that with every starting of a LUA script, all potential current running instances of the same script are killed immediately. So imagine you must for example wait in one of your script until the panel is reacting, before you trigger the next action. And if the user presses another key during the previous script is running, you might get unwanted results. When I started to implement some LUA scripts for buttons I first came also to your solution. But believe me, the event driven version is much better. Because the several events can be fired quite quickly without disturbing each other. And by utilizing the visibility of variables you can define global things for all functions. Rgds Reinhard Reinhard, thank you very much. I think I understand what you're saying regarding the event driven version. Good methods of doing things are always very important, of course. So I'll play with your code to make it work with a concrete hardware button or a knob, then I'll be able to switch completely to your version. I'm still missing how this part should look in a concrecte code: "joynum, button, downup". Could you give me a concrete example please, maybe from one of your lua's. Much thanks, Dirk. Link to comment Share on other sites More sharing options...
aua668 Posted March 28, 2013 Report Share Posted March 28, 2013 Hi, In the code above the joynum, button, downup are just parameters handed over to the called routine. They are not used in that specific case but there might be cases, where you want to identify, if the button was pressed or released and might do then different things. So the only thing to change in the example are the two lines at the end with the event registrations. Just replace joyletter and button1 resp. button2 with the items shown in the dialog, where you normally register button presses. I also would suggest to use letters instead of numbers for the joysticks. Details can be found in a different thread about lost assignments in this forum. And as these are basic concepts, how to create LUA programs, I would suggest that you look in the documentation provided with the LUA package. There are a lot of very useful sample scripts included, which you should try to understand. And if you have understood them by also studying the LUA library documentation, I think, things will be clearer. I am sorry but I am not able to provide LUA support more then given so far. I think by adopting the two lines and by starting the script automatically when your plane is loaded (look for the Auto section in the documentation), these two functions should work immediately without any further change (if you basic code brovided on the beginning was working). Get these two functions up and running and the rest will be easy. Rgds Reinhard Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 Reinhard, thanks, I'll try it now. If it works I'll be able to build up more on this example and some hacking. I know what you mean by using letters instead of numbers for the joysticks. At some point I used AutoAssignLetters=1 in FSUIPC.ini to name my joysticks by letters. But I did not understand the benefit, so I rolled back to Numbers. I have no obvious problems with numbering the joystics, are there any benefits with letters? Thanks, Dirk. Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 I forgot one important thing: FSUIPC does not assign letters to my GoFlight panels, so I can use only joynumber for GoFlight. Do you know if "joyletter" in your code can be substituted by "joynumber" or smth similar? Thanks, Sabre10 Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 Cool, it works. I see I don't need to assign any buttons in FSUIPC GUI all is done in the script. In my example: event.button(135, 0, 1, "toggleFD") where 135 is the number given by FSUIPC to one of my GF panels, and 0 is button #1 on it. Thanks! Dirk. Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 When there is no Toggle function, like when you turn HDG knob, what comes in place of toggleXXX? Much thanks, Dirk. Link to comment Share on other sites More sharing options...
aua668 Posted March 28, 2013 Report Share Posted March 28, 2013 Hi, You can keep AutoAssignLetters at 0 and manually assign them. For example Y for the Yoke etc. The problems will come, when you unplug the USB and plug it to a different port. Then a different number will be assigned. But the letter will stay. Think about hundred of modules, where you have to change the number. There are a lot of people, who learned this by pain. So it would be better to use the letters. It's all in the documentation. Rgds Reinhard Link to comment Share on other sites More sharing options...
aua668 Posted March 28, 2013 Report Share Posted March 28, 2013 ToggleXXX is just a function name. You can use whatever you like. Rgds Reinhard Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 Reinhard, I badly need just one more piece of your code for control of the rotary, to substitue the following: -- Heading dec if ipcPARAM == 24 then LVarSet = "L:AB_AP_HDG_Select" LVarGet = ipc.readLvar(LVarSet) ipc.writeLvar(LVarSet, LVarGet-1) end If I get another example of your method for the above, I'll have everything to start building the complete lua for all my input devices. Thanks, Dirk. Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 Hi, You can keep AutoAssignLetters at 0 and manually assign them. For example Y for the Yoke etc. The problems will come, when you unplug the USB and plug it to a different port. Then a different number will be assigned. But the letter will stay. Think about hundred of modules, where you have to change the number. There are a lot of people, who learned this by pain. So it would be better to use the letters. It's all in the documentation. Rgds Reinhard Yes, I've known about this problem since my first usb hubs 10+ yuears ago, therefore I've always had all usb connections fixed, photoed and written up in the notes, which takes a lot of time, of course, but still works. Now, assigning the letters in fsuipc.ini sounds much easier, thank you for the tip. Dirk. Link to comment Share on other sites More sharing options...
Dirk98 Posted March 28, 2013 Author Report Share Posted March 28, 2013 I've added 'Button On' case for Managed Heading mode selection to add to the "combined" event-driven lua: -- toggle FD buttonfunction toggleFD (joynum, button, downup)ipc.writeLvar( "L:AB_MPL_FD", 1 - ipc.readLvar("L:AB_MPL_FD") )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- toggle ATHR buttonfunction toggleILS (joynum, button, downup)ipc.writeLvar( "L:AB_MPL_ILS", 1 - ipc.readLvar("L:AB_MPL_ILS") )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- HDG mode selection managedfunction selectHDGmode (joynum, button, downup)ipc.writeLvar( "L:AB_AP_HDGmode", 1 )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- register the buttons of your joystick triggering the functions-- replace joyletter by the actual used letter/number, also replace buttonX by the actual valueevent.button(175, 0, 1, "toggleFD")event.button(175, 1, 1, "toggleILS")event.button(149, 1, 1, "selectHDGmode")[/CODE]Another couple of examples more from kind Lua gurus like Reinhard and I believe everyone will be able to map their HID devices to AXE functions with its SDK http://forum.aerosof...attach_id=38337. For me it's just a matter of seeing similarities and patterns in the code without understanding it, unfortunately. Lua manual and Lua Library are really beyond my depth, or too much time to study.As I see it there are 2 more templates needed:[CODE]-- Heading inc fastif ipcPARAM == 25 thenLVarSet = "L:AB_AP_HDG_Select"LVarGet = ipc.readLvar(LVarSet)ipc.writeLvar(LVarSet, LVarGet+10)end[/CODE]and[CODE]-- 55 HDGVS/TRKFPA button toggleif ipcPARAM == 55 thenLVarSet = "L:AB_AP_HDGTRK"LVarGet = ipc.readLvar(LVarSet)val = 1if ipc.readLvar(LVarSet) == 1 thenval = 0endipc.writeLvar(LVarSet, val)ipc.writeLvar("L:SmallOverheadPushButtons", 1)end[/CODE]I'll repeat, that Reinhard (aua668) kindly suggested another concept of scripting of the "combined" lua file for the access to AXE's internal variables (in this particular case), other than the one previously made by guenseli (in AX Lua script v1.2) and others that I saw. The lua based on Reinhard's method will work better than the parts that I quoted above, when you start mapping your HID devices, as with every starting of a LUA script, all potential current running instances of the same script are killed immediately. So imagine you must for example wait in one of your script until the panel is reacting, before you trigger the next action. And if the user presses another key during the previous script is running, you might get unwanted results. .... the event driven version is much better. Because the several events can be fired quite quickly without disturbing each other. And by utilizing the visibility of variables you can define global things for all functions. I think I've learnt a lot already without delving into programming. Just another couple of examples is needed. Thanks!Dirk. Link to comment Share on other sites More sharing options...
aua668 Posted March 28, 2013 Report Share Posted March 28, 2013 Reinhard, maybe you can figure this out: In AXE SDK among others there are 3 specific LVars for V/S - FPA knob, that are: AB_AP_VS_Select2 AB_AP_HDGTRK AB_AP_FPA_Select2 HDGTRK button switches mode between VS_Select2 and FPA_Select2 modes. I'm not sure if this can somehow be merged so that one V/S hardware wheel (or knob) could understand and control both VS or FPA, depending on the mode changed by HDGTRK button. What I mean is that now I can only map my hardware VS wheel either to VS_Select2 or FPA_Select2. Obviously pressing HDGTRK button immediately loses control of the currently mapped function (VS_Select2 or FPA_Select2 depending on the script used). So, how to make the script explain and hand over control of the next function (VS or FPA code) to my hardware wheel each time HDGTRK is pressed? Thanks. Dirk. Let's try something like this: function incFPAorVS ( joynum, button, downup )if ipc.readLvar("L:AB_AP_HDGTRK") == 1 then -- 1 = TRK/FPA local lFPA = ipc.readLvar( "L:AB_AP_FPA_Select2" ) + 0.1 if lFPA > 9.9 then lFPA = 9.9 end if ipc.writeLvar( "L:AB_AP_FPA_Select2", lFPA )else -- 0 = HDG/SPD so set VS local lVS = ipc.readLvar( "L:AB_AP_VS_Select2" ) + 1 if lVS > 60 then lVS = 60 end if ipc.writeLvar( "L:AB_AP_VS_Select2", lVS )endend-- register the buttons of your joystick triggering the functions-- replace joynum by the actual used number, also replace button by the actual button numberevent.button(joynum, button, 1, "incFPAorVS")[/CODE]Not sure if it works, as I have no way to test it. And the code for decrementing could easily be done by copy/paste and edit I assume.RgdsReinhard Link to comment Share on other sites More sharing options...
aua668 Posted March 28, 2013 Report Share Posted March 28, 2013 Reinhard, I badly need just one more piece of your code for control of the rotary, to substitue the following: -- Heading dec if ipcPARAM == 24 then LVarSet = "L:AB_AP_HDG_Select" LVarGet = ipc.readLvar(LVarSet) ipc.writeLvar(LVarSet, LVarGet-1) end If I get another example of your method for the above, I'll have everything to start building the complete lua for all my input devices. Thanks, Dirk. let's try something like this: function incdecHDG ( pDiff ) -- increment or decrement HDG by pDifflocal lHDG = ipc.readLvar( "L:AB_AP_HDG_Select" ) + pDiffif lHDG > 359 then lHDG = lHDG - 360end ifif lHDG < 0 then lHDG = lHDG + 360end ifipc.writeLvar( "L:AB_AP_HDG_Select", lHDG )endfunction incHDG ( joynum, button, downup )incdecHDG ( 1 )endfunction decHDG ( joynum, button, downup )incdecHDG ( -1 )endfunction incHDGFast ( joynum, button, downup )incdecHDG ( 10 )endfunction decHDGFast ( joynum, button, downup )incdecHDG ( -10 )end-- register the buttons of your joystick triggering the functions-- replace joynum by the actual used number, also replace button by the actual button numberevent.button(joynum, button1, 1, "incHDG")event.button(joynum, button2, 1, "decHDG")event.button(joynum, button3, 1, "incHDGFast")event.button(joynum, button4, 1, "decHDGFast")[/CODE]I prepared the code for registering four buttons. Two for normal incrementing decrementing by 1 degree and in case yor hardware delivers other buttons if you turn the knob quickly then the increment will be in steps of 10. But this depends on your hardware. GoFlight for example does it like that.RgdsReinhard Link to comment Share on other sites More sharing options...
Dirk98 Posted March 29, 2013 Author Report Share Posted March 29, 2013 Woo-hooo, Reinhard! You are the King! (lua king) Thank you very much for your time spent on this. Can't wait to work on your script, dig hard into it and try out on the hardware. I have a dozen+ of GF panels, VRinsight MS Panel, (VRI FCU 2 Airbus is in the pipe) and many more that I don't use, lol. My interest atm mainly revolves around GF (MCP, RP48, GF166A VRP, GF-LGT II) and some others. Guys with GoFlight panels, if you've found this, ask me! I'll post my results for the latest scripts. Thanks again, Dirk. Link to comment Share on other sites More sharing options...
Dirk98 Posted March 29, 2013 Author Report Share Posted March 29, 2013 Let's try something like this: function incFPAorVS ( joynum, button, downup )if ipc.readLvar("L:AB_AP_HDGTRK") == 1 then -- 1 = TRK/FPAlocal lFPA = ipc.readLvar( "L:AB_AP_FPA_Select2" ) + 0.1if lFPA > 9.9 thenlFPA = 9.9end ifipc.writeLvar( "L:AB_AP_FPA_Select2", lFPA )else -- 0 = HDG/SPD so set VSlocal lVS = ipc.readLvar( "L:AB_AP_VS_Select2" ) + 1if lVS > 60 thenlVS = 60end ifipc.writeLvar( "L:AB_AP_VS_Select2", lVS )endend-- register the buttons of your joystick triggering other functions-- replace joynum by the actual used number, also replace button by the actual button numberevent.button(joynum, button, 1, "incFPAorVS")[/CODE]Not sure if it worksNo, unfortunately it does not. The current lua looks as follows and[u][b] none of the functions work[/b][/u]:[CODE]-- toggle FD buttonfunction toggleFD (joynum, button, downup)ipc.writeLvar( "L:AB_MPL_FD", 1 - ipc.readLvar("L:AB_MPL_FD") )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- toggle ATHR buttonfunction toggleILS (joynum, button, downup)ipc.writeLvar( "L:AB_MPL_ILS", 1 - ipc.readLvar("L:AB_MPL_ILS") )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- HDG mode selection managedfunction selectHDGmode (joynum, button, downup)ipc.writeLvar( "L:AB_AP_HDGmode", 1 )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- VS/FPA Toggle codefunction incFPAorVS ( joynum, button, downup )if ipc.readLvar("L:AB_AP_HDGTRK") == 1 then -- 1 = TRK/FPAlocal lFPA = ipc.readLvar( "L:AB_AP_FPA_Select2" ) + 0.1if lFPA > 9.9 thenlFPA = 9.9end ifipc.writeLvar( "L:AB_AP_FPA_Select2", lFPA )else -- 0 = HDG/SPD so set VSlocal lVS = ipc.readLvar( "L:AB_AP_VS_Select2" ) + 1if lVS > 60 thenlVS = 60end ifipc.writeLvar( "L:AB_AP_VS_Select2", lVS )endendevent.button(175, 4, 1, "incFPAorVS")event.button(175, 0, 1, "toggleFD")event.button(175, 1, 1, "toggleILS")event.button(149, 1, 1, "selectHDGmode")[/CODE]However when I change back to:[CODE]-- toggle FD buttonfunction toggleFD (joynum, button, downup)ipc.writeLvar( "L:AB_MPL_FD", 1 - ipc.readLvar("L:AB_MPL_FD") )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- toggle ATHR buttonfunction toggleILS (joynum, button, downup)ipc.writeLvar( "L:AB_MPL_ILS", 1 - ipc.readLvar("L:AB_MPL_ILS") )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )end-- HDG mode selection managedfunction selectHDGmode (joynum, button, downup)ipc.writeLvar( "L:AB_AP_HDGmode", 1 )ipc.writeLvar( "L:SmallOverheadPushButtons", 1 )endevent.button(175, 0, 1, "toggleFD")event.button(175, 1, 1, "toggleILS")event.button(149, 1, 1, "selectHDGmode")[/CODE]the above functions work fine again.Thanks,Dirk.PS: Also, in this script for VS/FPA switching I don't see event buttons for VS incr/decr and FPA incr/decr, even though you added ipc.writeLvar( "L:AB_AP_FPA_Select2", lFPA ) and ipc.writeLvar( "L:AB_AP_VS_Select2", lVS ) functionality (I mean turning the VS/FPA knob) if I got it right.For your reference the previous 2 LUAs for turning VS +/- looked like this:-- VS DecLVarSet = "L:AB_AP_VS_Select2"LVarGet = ipc.readLvar(LVarSet)ipc.writeLvar(LVarSet, LVarGet-1)-- VS IncLVarSet = "L:AB_AP_VS_Select2"LVarGet = ipc.readLvar(LVarSet)ipc.writeLvar(LVarSet, LVarGet+1)otherwise they were combined in one big LUA as follows:-- V/S incif ipcPARAM == 53 thenLVarSet = "L:AB_AP_VS_Select2"LVarGet = ipc.readLvar(LVarSet)ipc.writeLvar(LVarSet, LVarGet+1)end-- V/S decif ipcPARAM == 54 thenLVarSet = "L:AB_AP_VS_Select2"LVarGet = ipc.readLvar(LVarSet)ipc.writeLvar(LVarSet, LVarGet-1)end-- 56 FPA incif ipcPARAM == 56 thenLVarSet = "L:AB_AP_FPA_Select2"LVarGet = ipc.readLvar(LVarSet)ipc.writeLvar(LVarSet, LVarGet+0.1)end-- 57 FPA decif ipcPARAM == 57 thenLVarSet = "L:AB_AP_FPA_Select2"LVarGet = ipc.readLvar(LVarSet)ipc.writeLvar(LVarSet, LVarGet-0.1)endThanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now