Jump to content
The simFlight Network Forums

FSUIPC WASM module + client-side API + lvar/hvar discussion topic


John Dowson

Recommended Posts

3 hours ago, Nenad Bogojevic said:

Is it or will it be possible to call execute calculator code from lua scripts?

I added a lua function for his yesterday, but still not tested or released... I'm still queued for the current update that fixes the CTD when using standalone WASMs. Once tested, I'll release this as the next beta update, with the installer updated for the WASM & hopefully with updated documentation, in the next day or two.

There is one major difference to the lua version though - it will have a max argument (i.e. calc. code string size) of 64 characters. I can maybe look into changing this if there is a need, but that would have to be a post-release update..

Cheers,

John

 

Link to comment
Share on other sites

When I am in MSFS developer mode looking at the CRJ, I can see the LVAR variables for speed, heading, vertical speed, altitude varying when I turn the knobs. These variables are: ASCRJ_FCP_SPEED_INFO, ASCRJ_FCP_HDG_INFO,ASCRJ_FCP_WHEEL_INFO, ASCRJ_FCP_ALT_INFO. 
 
Is there a way to read these variable and pass them onto Mobiflight?
 
 
 
 
Link to comment
Share on other sites

13 hours ago, Helibrewer said:

Some of the H135 guys are asking if they need to have FSUIPC7 registered to play with this....I wasn't sure since mine is registered.

You need a registered FSUIPC7 to use lvars/havrs in FSUIPC7. The WASM is free to use & distribute as you wish, and thw WAPI (and test client) are open source, so you can use that however you wish.

  • Like 1
Link to comment
Share on other sites

15 hours ago, erocfx said:

Is there a way to read these variable and pass them onto Mobiflight?

I don't use MobiFlight (except for the MF WASM module), but I think MobiFlight uses FSUIPC offsets, so you could read the lvars in a lua script (using event.lvar) and populate some user offsets with the values to be read by MobiFilight.

  • Like 1
Link to comment
Share on other sites

On 4/13/2021 at 1:50 PM, Helibrewer said:

Ah, I see that now, thanks again and thanks for all the work on this. Looking forward to figuring out how to utilize this in lua scripts in the future.

Me too, also make intensive use of Aircraft dependant lua files to setup and handle things.

Eager to see this becoming available.

Link to comment
Share on other sites

3 hours ago, SAC002 said:

Looking for instructions on how to retreive lvars and hvars from msfs2020...

lvars are auto-discovered by the WASM, and you can re-initiate a scan at any tine by issuing a 'Reload' command (from any WASM client, such as the test Client or FSUIPC7).

For hvars, you will have to find them yourself. I have provided a hvar file for the A320 (constructed form the MobiFlight spreadsheet), but you need to search for hvars yourself i'm afraid. There were instructions on how to do this on the Asobo forums a few months ago, but I have been unable to find that post since. I have also asked for users to supply these if found, but have received nothing so far on this. Hvars are new to MSFS, and there is scant info on how to find/use at the moment...

I will look into these further when time permits.  However, for the time being I would like to concentrate on getting lvar functionality via FSUIPC up & running & reliably. I have provided access to hvars, but there use is really down to the user...

John

 

  • Like 1
Link to comment
Share on other sites

12 hours ago, John Dowson said:

so you could read the lvars in a lua script (using event.lvar) and populate some user offsets with the values to be read by MobiFilight.

Thanks John. Is there an example of an event.lvar script? I can't seem to find it. I think this would work great.

Link to comment
Share on other sites

11 hours ago, erocfx said:

Is there an example of an event.lvar script? I can't seem to find it. I think this would work great.

No, but its pretty straightforward. Take a look at the Lua library documentation for event.lvar. In your processing function you just need to use one of the ipc.writeXXX functions (where XXX is the type of the lvar, usually a DBL but can also be an int or other type). For the offset, you can use 0x66C0-0x66FF, or 512bytes from 0xA000. So, try for yourself, and post again if you have any issues.

Link to comment
Share on other sites

3 hours ago, John Dowson said:

No, but its pretty straightforward. Take a look at the Lua library documentation for event.lvar. In your processing function you just need to use one of the ipc.writeXXX functions (where XXX is the type of the lvar, usually a DBL but can also be an int or other type). For the offset, you can use 0x66C0-0x66FF, or 512bytes from 0xA000. So, try for yourself, and post again if you have any issues.

Hi John,

Where can i find this Lua Library ducumentation, the only Lua library documentation i find is the one i got with the registered version of FSUIPC7 but that doesn't mention Lvar support.

Link to comment
Share on other sites

37 minutes ago, LeoSchoonbroodt said:

Where can i find this Lua Library ducumentation, the only Lua library documentation i find is the one i got with the registered version of FSUIPC7 but that doesn't mention Lvar support.

Yes, sorry, the lvar functions were removed as they previously weren't available. I've added this back now, and also added the new functions, but I haven't released the updated documentation yet. I will do this in the next beta release, including the installer, either later this evening or tomorrow.

You should still have the FSUIPC Lua Library.pdf in your documents folder, for the ipc.writeXXX functions. Here's the additional documentation:

Quote
ipc.activateHvar(“name”)
[Not WideClient]

This writes to the FS HTML panel variable called “name”. These are H: <name> variables. The H: part must be included. If the variable is not currently available, nothing happens.

N.B. To use this function, the FSUIPC WASM module must be installed, and the WASM interface active in FSUIPC7.

 

ipc.createLvar(“name”,
initialValue)

[Not WideClient]

This creates a new FS local panel variable called “name” and sets its initial value. These are L: <name> values. You can provide the L: part explicitly or leave it out.

N.B. To use this function, the FSUIPC WASM module must be installed, and the WASM interface active in FSUIPC7.

 

n = ipc.getLvarId(“name”)
[Not WideClient]

This gets the ID of the current FS local panel variable identified bythe name given. These variables are L: <name>. You can provide the L: part explicitly or leave it out.
The value returned is numeric in the range 0 to 65535, or
nil if the variable is not available.

N.B. To use this function, the FSUIPC WASM module must be installed, and the WASM interface active in FSUIPC7.

 

n = ipc.getLvarName(id)
[Not WideClient
This gets the name of the current FS local panel variable identified by the id value, a numeric in the range 0 to 65535. These variables are L: <name> , but the result provided is only the ,name> part,
without the L: The value returned is a string, or
nil if the variable is not available.
To get all current LVars you can iterate from 0 upwards until
nil is returned.

N.B. To use this function, the FSUIPC WASM module must be installed, and the WASM interface active in FSUIPC7.

 

n = ipc.readLvar(“name”)
n = ipc.readLvarSTR(“name”)

[Not WideClient]
This reads the current value of the FS local panel variable called “name”. These are L: <name> values. You can provide the L: part explicitly or leave it out.
The value returned from
readLvar is numeric, or nil if the
variable is not available, and from
readLvarSTR will be a
string or
nil.

N.B. To use this function, the FSUIPC WASM module must be installed, and the WASM interface active in FSUIPC7.

 

ipc.writeLvar(“name”, n)
ipc.writeLvarSTR(“name”, “value”)

[Not WideClient]
This writes to the FS local panel variable called “name”. These are L: <name> values. You can provide the L: part explicitly or leave it out.
If the variable is not currently available, nothing happens.

N.B. To use this function, the FSUIPC WASM module must be installed, and the WASM interface active in FSUIPC7.

 

event.Lvar("lvarname", interval,
"function-name", userParameter)
Your processing function:
function-name(varname, value,
userParameter)

[Not WideClient]

This monitors the value of the given local gauge variable ("L:Var") at the given interval, and calls the function when it a change in the value is detected. Both the lvar name and value, together with an optional (integer) user parameter are passed to the specified function. The L:var name can be in the form "L:name" or just "name", but when our declared function is called the name provided is without it's L: part. It is provided in the call so that the same
function can be used for multiple variables if required.
The interval is in milliseconds and has a minimum value of 100. it is not optional.
The function will never be called if there is no matching L:Var, so you need not worry about checking the correct aircraft or gauge is loaded. No error will occur.

N.B. To use this function, the FSUIPC WASM module must be installed, and the WASM interface active in FSUIPC7.

 

ipc.execCalcCode(“code”)
[Not WideClient]
This executes the argument code using the Panels
execute_calculator_code method.

N.B. To use this function, the FSUIPC WASM module must be installed, and the WASM interface active in FSUIPC7.

 

 

  • Thanks 1
Link to comment
Share on other sites

41 minutes ago, John Dowson said:

Yes, sorry, the lvar functions were removed as they previously weren't available. I've added this back now, and also added the new functions, but I haven't released the updated documentation yet. I will do this in the next beta release, including the installer, either later this evening or tomorrow.

You should still have the FSUIPC Lua Library.pdf in your documents folder, for the ipc.writeXXX functions. Here's the additional documentation:

 

Thanks John,

Tried it but cannot access the Lvars with the FSUIPC7  version 7.1.0d althoug i have the WASM module installed, can access and set Lvars with the testclient and have enabled the WASM module under Add-ons in FSUIPC7.

See that the other options in the WASM submenu  of FSUIPC7 (List Lvars, List Hvars Set Lvar etc) are all grayed out, only disable is available.

Also event.Lvar in my lua script is not triggered when the Lvar value changes, so i think i still have problems accessing Lvars via lua.

 

I used the lua documentation from FSUIPC4 and FSUIPC7 extensively, was only missing Lvar documentation.

Thanks for that.

Link to comment
Share on other sites

2 minutes ago, LeoSchoonbroodt said:

See that the other options in the WASM submenu  of FSUIPC7 (List Lvars, List Hvars Set Lvar etc) are all grayed out, only disable is available.

If they are grayed-out, this indicates that the WAPI IF is not active, usually because you are in a main menu on MSFS rather than having a plane loaded and 'ready-to-fly'. If you were in this state, try restarting FSUIPC7.

Also, if using beta facilities you should use the latest, which is now 7.1.0.e.

6 minutes ago, LeoSchoonbroodt said:

Also event.Lvar in my lua script is not triggered when the Lvar value changes, so i think i still have problems accessing Lvars via lua.

Nothing will work if the WASM menu entries are grayed-out, as the WAPI interface isn't initialised. Anyway, update and try again.
 

  • Like 1
Link to comment
Share on other sites

10 minutes ago, John Dowson said:

If they are grayed-out, this indicates that the WAPI IF is not active, usually because you are in a main menu on MSFS rather than having a plane loaded and 'ready-to-fly'. If you were in this state, try restarting FSUIPC7.

Also, if using beta facilities you should use the latest, which is now 7.1.0.e.

Nothing will work if the WASM menu entries are grayed-out, as the WAPI interface isn't initialised. Anyway, update and try again.
 

John, your the best,

I had the Model Behaviors window open to monitor the Lvar changes.

I have closed that and restarted FSUIPC7 and it works all.

I was indeed on version 7.1.0e, my mistake.

Now everything worked!!!

Thanks

Link to comment
Share on other sites

4 minutes ago, Nenad Bogojevic said:

Just to thank you for new version. I've tested ipc.execCalcCode and it worked as expected. 

Great, thanks for letting me know.

And thanks for the hvar file, I will include that in the next release. Which also reminds me, I need to add something about hvars and hvars files to the documentation....

Cheers,

John

Link to comment
Share on other sites

Hi, I think I am getting close but I seem to be missing something about macros to control LVARS...

I want to control the XMLVAR_APTRIM Lvar for the TBM930.

I have created a macro named: XMLVAR_APTRIM.mcro and put it in my main FSUIPC folder.

It has 2 lines: 

[Macros]

1=L:XMLVAR_APTRIM=Set,0

 

I don't see this command in the drop down menu for assigning a button ?

Thanks for your help.

Daniel

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.