Jump to content
The simFlight Network Forums

HVAR not working in LUA but same calculator code works


Recommended Posts

Posted

Hi John, I use LUA for managing LVARS and all works very well. Since I use OpenCockpits MCP and EFIS, I have to use some offsets ("A001, A002, A003...") to allow LUA to detect OC buttons or knobs, and then it sets the LVARS properly. So this code works perfectly (with default Asobo A320 neo) :

function MFD_RANGE_SET()
    MFD_range = ipc.readUB(0xA001)
    ipc.writeLvar("L:A320_Neo_MFD_Range", MFD_range)
end

event.offset("A001","UB", "MFD_RANGE_SET")

When offset A001 changes (controlled by my O.C. EFIS range knob, the Lvar is set correctly.

I tried to handle also HVARS :

function PFD_ILS_MODE()
    ILS_BTN = ipc.readUB(0xA004)
    if ILS_BTN == 1 then
       ipc.activateHvar("H:A320_Neo_PFD_BTN_LS")
    end
end

event.offset("A004","UB", "PFD_ILS_MODE")

This DOESN'T WORK, but if I replace the activateHvar with calculator code, it works perfectly

function PFD_ILS_MODE()
    ILS_BTN = ipc.readUB(0xA004)
    if ILS_BTN == 1 then
       ipc.execCalcCode("(>H:A320_Neo_PFD_BTN_LS)")
    end
end

event.offset("A004","UB", "PFD_ILS_MODE")

What I am doing wrong with ipc.activateHvar ?

No problems for me to use calculator code, but I would like to understand why ipc.activateHvar doesn't work.

The same happens with other Hvars, all work in calculator code but not in ipc.activateHvar.

Maybe that this happens because I can't find those Hvars under wasm --> list Hvars, but the calculator code finds them. How can I add them to FSUIPC ?

Posted

Two things:

1. Lvar and hvar handling is broken in the current released version 7.3.8 since SU10. You need to update to the latest beta release 7.3.9i, available from 

 

2. Hvars are only known to FSUIPC if you have provided them in a *.hvar file, named accordingly so loaded with the aircraft. This is described in the WASM section of the Advanced User guide. Please review section. Only a few such files are provided by FSUIPC out-of-the-box, and I generate these quite some time ago and so are probably not up to date (i.e. may not contain all known hvars).

However, there is no problem activating hvars or setting lvars using calculator code, and doing so by-passes the need for FSUIPC7 to know about them. 

If you want to use a *.hvar file though, if you create a new one or update any existing one, if you could share that with me I can add it to the installer so that it can be used by others.

Regards,

John

Posted

Thanks John,

I agree, using calculator code in lua is an extremely powerful and useful option, so probably I won't use activateHvars, that initially seemed more straightforward and easy, but in the end calculator code is probably the most effective tool and can do almost everything!

Best regards

Massimo

Posted

Yep. there is not really much use of the *.hvar files any more unless you want to use them in macros. They are helpful to see what hvars are available though - but then you need this file provided so someone has to create this file in the first place.

Note also that you can call presets from lua using ipc.writeSTR to offset 0x7C50. I am planning to add an ipc.preset or ipc.executePreset lua function to make this easier.

Cheers,

John

Posted

Ok very interesting.

I fixed the Hvar issue following your indications

1) updated with lates beta 3.9

2) added to A320.hvar under "modules" folder these 2 lines :

H:A320_Neo_MFD_BTN_ARPT
H:A320_Neo_PFD_BTN_LS

And now also ipc.activateHvar works perfectly.

 

Posted
12 minutes ago, AlMassimo said:

2) added to A320.hvar under "modules" folder these 2 lines :

H:A320_Neo_MFD_BTN_ARPT
H:A320_Neo_PFD_BTN_LS

Ah, ok. I can add them - there are already those hvars but with '_1' and '_2' appended.

Posted

Yes they are for FBW A320 (or "A32NX") that has different controls for left and right seat switches. Most of FBW variables are "A32NX_something" but probably the first added were still "A320_something" and this causes some confusion, since they are difficult to distinguish from default A320 variables.

It could be a good thing to have different hvar files for A320 and FBW A32NX.

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.