Jump to content
The simFlight Network Forums

LUA: read simvars?


Recommended Posts

13 hours ago, Mugz said:

It's possible to read simulator variable in LUA script?

You can read simulator variables that are held in offsets, using the lua ipc.readXXX functions.
If the simvar is not yet held in an offset, you can request it to be added.

John

Link to post
Share on other sites
4 hours ago, John Dowson said:

You can read simulator variables that are held in offsets, using the lua ipc.readXXX functions.
If the simvar is not yet held in an offset, you can request it to be added.

Got it. And how to do same for LVARS? (i see new feature in 7.2.0 version)

Link to post
Share on other sites
1 hour ago, Mugz said:

And any examples?

Yes, many. See the offset document spreadsheet - this gives the simvar names (where relevant) for the offset address.
For reading/writing to these offsets via lua. check out the lua examples provided.

Link to post
Share on other sites
1 hour ago, Mugz said:

Got it. And how to do same for LVARS? (i see new feature in 7.2.0 version)

For lvars, you can use the new lvars-to-offsets facility, available by editing the FSUIPC7.ini. See the Advanced User Guide for details and an example.

Link to post
Share on other sites
19 hours ago, John Dowson said:

Yes, many. See the offset document spreadsheet

image.png.150227fb4cdcf60148262a75db056759.png

where is offset information about MSFS?
Didnt find any simpliest example in Advanced User Guide, can you point me please?

Also additional question. If i exit from sim, all lua scrips instantly killed, i can handle property exit? For example if i get sim exit - run specified function, and then exit?

Link to post
Share on other sites

As the message you quoted says, the spreadsheet comes in the zip file that you downloaded.

9 minutes ago, Mugz said:

Didnt find any simpliest example in Advanced User Guide, can you point me please?

The example lua programs can be found in your FSUIPC7 Documents folder, bundled together in a zip file called Example LUA plugins.zip.

11 minutes ago, Mugz said:

Also additional question. If i exit from sim, all lua scrips instantly killed, i can handle property exit? For example if i get sim exit - run specified function, and then exit?

Of course all lua scripts are exited when you exit the Sim. FSUIPC7 also exits when the sim exits, if it is started by MSFS, and all programs started by FSUIPC7 will also exit.
Why would you want to run anything when MSFS is exiting?  Once the sim is exiting, there is nothing that can be done except shut-down gracefully.
 

Link to post
Share on other sites
3 minutes ago, John Dowson said:

As the message you quoted says, the spreadsheet comes in the zip file that you downloaded.

I didnt find. Name of file?

3 minutes ago, John Dowson said:

The example lua programs can be found in your FSUIPC7 Documents folder, bundled together in a zip file called Example LUA plugins.zip.

I see a lot example, which one i can use to understand proccess?

4 minutes ago, John Dowson said:

Why would you want to run anything when MSFS is exiting?  Once the sim is exiting, there is nothing that can be done except shut-down gracefully.

For example.

I have default led state on my devices. When my LUA work - it's change some LED's to different state. If i exit from sim, all my leds keep color state, i want to RESET all led states if sim exit.

Link to post
Share on other sites
5 minutes ago, Mugz said:

If i exit from sim, all my leds keep color state, i want to RESET all led states if sim exit.

Check the Lua Library document for event.terminate.  That will call a function in your plug-in which can turn off your LEDs.

If you don't understand Lua itself you will find lots of assistance on www.lua.org. There are also several good books on it -- start with "Beginning Lua Programming". 

But for many simply things the examples provided in the ZIP file should help. mostly, in simply plug-ins, the code is almost all calls to FSUIPC provided library functions, documented in the Lua Library PDF.

We can help if you don't understand the library functions, but we cannot undertake to teach Lua.

Pete

 

Link to post
Share on other sites
1 minute ago, Pete Dowson said:

But for many simply things the examples provided in the ZIP file should help. mostly, in simply plug-ins, the code is almost all calls to FSUIPC provided library functions, documented in the Lua Library PDF.

Actualy i ask help to point which lua script show me examples how to operate with SimVars through offsets.

Link to post
Share on other sites
15 minutes ago, Mugz said:

Actualy i ask help to point which lua script show me examples how to operate with SimVars through offsets.

Reading offsets to get sim values is just a matter of using the relevant ipc.readXXX library function. You would need to refer to the Offset list to find the values you want , noting the offset value (0x????) and the size (signed or unsigned, byte, word, dword, float double or string), and read them in your script using the appropriate ipc.readXXX function.

Many of the example Lua plug-ins provided show uses of these functions. Take the VAS_Monitor or the ThrustSym ones, for instance.

You need to make a little effort to help yourself.  We cannot spoon-feed you. Sorry.

Pete

 

 

Link to post
Share on other sites
18 minutes ago, Pete Dowson said:

You need to make a little effort to help yourself.  We cannot spoon-feed you. Sorry

I'm not asking you to spoon feed me. I am asking you to help me sort out your product and documentation, which is somewhat chaotic. It would be great if some aspects were described in more detail, rather than general theses.

I only ask questions that I can't figure out. For example, misunderstanding the work of offsets with MSFS, misunderstanding of the work of the timings of the lua script, asked about a specific example of working with the simvar, tk. the archive contains a bunch of scripts, it's hard to read each one to understand what it does.

In fact, I just asked for certain specifics.

Sorry if this turned out to be difficult and time-consuming for you.

Link to post
Share on other sites
30 minutes ago, Mugz said:

In fact, I just asked for certain specifics.

I'm actually retired and have little to do with MSFS, and John doesn't work 24/7. I'm just trying to help.

And you are not asking specifics. A specific is stating exactly what to want to accomplish, specifically, and then we can assist, specifically.

Incidentally, if you truly want SimConnect SimVars as opposed to values derived from those and written for you into offsets, then why aren't you using the SimConnect SDK instead? Please do go and have a look and see how easy that is.

I'm going out soon so there may be a delay till a further reply, unless you are very quick.

Pete

Link to post
Share on other sites
1 hour ago, Mugz said:

I didnt find. Name of file?

This one: offsetStatus-v0.21.ods

40 minutes ago, Mugz said:

I only ask questions that I can't figure out.

Try reading the manuals. For general lua information, use google. To find out how lua plugins work with FSUIPC, read the FSUIPC Lua Plug-Ins.pdf document. This also contains an overview of the provided examples. Then, for specific on the FSUIPC lua library, take a look at the FSUIPC Lua Library.pdf document.
Also check-out the User Contributions and FAQ sub-forums on this support site.

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • 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.