Jump to content
The simFlight Network Forums

trying to send value to LVAR by button


Recommended Posts

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.