shorthauler Posted September 16, 2023 Report Posted September 16, 2023 Hi folks, I have an 8-position-switch (A320 EFIS mode selector), so this corresponds to 8 seperate buttons. I have set up these buttons to call a Lua script ("Control sent when button pressed"). Every button calls the same Lus script but sends different parameters (0, 10, 20, 30, 40). The parameters are supposed to set an Lvar state that will select the respective mode (LSm VOR, NAV, ARC, PLAN). This is for FSUIPC4. Ths Lua script consist of one single line: ipc.writeLvar("VC_GSLD_CP_EFIS_ND_Mode_Knob", ipcPARAM) This is where I started. I have read up on parameters in the Advanced Users, Library and Plug-In documents and all kinds of variations, but to no avail. I am probably missing something very simple here, so apologies in advance. Any input will be much appreciated. Best regards, - shorthauler
John Dowson Posted September 16, 2023 Report Posted September 16, 2023 4 minutes ago, shorthauler said: I have an 8-position-switch (A320 EFIS mode selector), so this corresponds to 8 seperate buttons. I have set up these buttons to call a Lua script ("Control sent when button pressed"). Every button calls the same Lus script but sends different parameters (0, 10, 20, 30, 40). The parameters are supposed to set an Lvar state that will select the respective mode (LSm VOR, NAV, ARC, PLAN). This is for FSUIPC4. Ths Lua script consist of one single line: ipc.writeLvar("VC_GSLD_CP_EFIS_ND_Mode_Knob", ipcPARAM) That sounds reasonable... 5 minutes ago, shorthauler said: Any input will be much appreciated. Please activate debugging for Debug/Trace Lua plugins (NOT Log Lua plugins separately) as well as Button and Key operations and generate a log file showing your issue. Please also list the lvars before you move your 8 position rotary so that I can check the lvar exists (you can assign a spare button or key press to do this, either using the List local panel variables control, or the provided Log Lvars.lua), as well as after you have turned your rotary to check if the value has changed or not. Then show me / attach your FSUIPC4.log and FSUIPC4.ini files together with your lua script. John
shorthauler Posted September 16, 2023 Author Report Posted September 16, 2023 Dear John, Problem solved - I had the Lua scrip running continuously due to a faulty Auto entry in FSUIPC.INI My sincere apologies for taking your time! Best regards, Holger
John Dowson Posted September 17, 2023 Report Posted September 17, 2023 12 hours ago, shorthauler said: I had the Lua scrip running continuously due to a faulty Auto entry in FSUIPC.INI No problem. Note it would be more efficient if you changed the script to something like: Quote function modeKnob(param) ipc.writeLvar("VC_GSLD_CP_EFIS_ND_Mode_Knob", param) end event.param("modeKnob") have the script auto-started, and assign your rotary buttons to the LueValue <script> control to set the parameter. Doing this, the lua script is only compiled once and you should get better performance. John
shorthauler Posted September 17, 2023 Author Report Posted September 17, 2023 Thank you for your comment. I seem to have a lack of understanding - I set up the script in a way that it is triggered only when the button is actuated. I thought this would be more efficient than having ths script running in the background the whole time. Seems I am wrong? Holger
John Dowson Posted September 18, 2023 Report Posted September 18, 2023 13 hours ago, shorthauler said: I set up the script in a way that it is triggered only when the button is actuated. I thought this would be more efficient than having ths script running in the background the whole time. Seems I am wrong? There is no problem having the script ran on a button press. However, this means that a new thread is created & started and the script is compiled (before being ran) an each button press, which introduces a small overhead/delay on each button press. Having the script auto-ran and activating on events is generally more efficient as the the thread generation and script compilation is only done once (and at start-up) rather than on each button press. John
shorthauler Posted September 29, 2023 Author Report Posted September 29, 2023 (edited) (I might have a mistake there, I will check later today and report.) Hi John, You recommend setting the buttons to the LuaValue command, but for me it only works with the normal Lua command. I wonder what I am doing wrong. Best regards -shorthauler Edited September 30, 2023 by shorthauler Possible mistake
John Dowson Posted September 30, 2023 Report Posted September 30, 2023 I can't help if you don't show me your files. Are you sure that your lua script is running? When using LuaValue, your script should be auto-started from your [Auto] or [Auto.xxx] (profile) section of your FSUIPC ini file.
shorthauler Posted October 3, 2023 Author Report Posted October 3, 2023 I found my mistake - Notepad++ does not save files on exit. However, it will show the modified file when you open it again. So I assumed my script was saved, but it was not. It all works fine now. Thanks a lot for your help!
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