Mugz Posted June 10, 2021 Report Posted June 10, 2021 It's possible to read simulator variable in LUA script? Where i can look example?
John Dowson Posted June 11, 2021 Report Posted June 11, 2021 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
Mugz Posted June 11, 2021 Author Report Posted June 11, 2021 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)
John Dowson Posted June 11, 2021 Report Posted June 11, 2021 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.
John Dowson Posted June 11, 2021 Report Posted June 11, 2021 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.
Mugz Posted June 12, 2021 Author Report Posted June 12, 2021 19 hours ago, John Dowson said: Yes, many. See the offset document spreadsheet 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?
John Dowson Posted June 12, 2021 Report Posted June 12, 2021 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.
Mugz Posted June 12, 2021 Author Report Posted June 12, 2021 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.
Pete Dowson Posted June 12, 2021 Report Posted June 12, 2021 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
Mugz Posted June 12, 2021 Author Report Posted June 12, 2021 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.
Pete Dowson Posted June 12, 2021 Report Posted June 12, 2021 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
Mugz Posted June 12, 2021 Author Report Posted June 12, 2021 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.
Pete Dowson Posted June 12, 2021 Report Posted June 12, 2021 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
John Dowson Posted June 12, 2021 Report Posted June 12, 2021 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.
joeherwig Posted October 8, 2022 Report Posted October 8, 2022 On 6/11/2021 at 11:08 AM, 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. John Hi John, As MSFS SDK offers also the Z:Vars - which are A:Vars aka SimVars that can be assigned by the aircraft designer it is currently not possible to read values from some aircraft like AS33ME. See: documentation attached. Adding those directly to FSUIPC offsets seems to be a nightmare for you as the devs might change them quite often... So is there any option to read the values of that simvars other than requesting it for each variable at you? Writing it is no issue using calculator code. So it's just about reading the values of those vars...
John Dowson Posted October 9, 2022 Report Posted October 9, 2022 As far as I am aware, there is no access to z vars provided by the the SDK. But you say they are A:vars aka simvars....so what is the difference between a Z and and and A var? If they are treated the same via the SDK, then you can just use the facilities provided by FSUIPC to add any available simvar to an offset. Otherwise, if they are more like L:vars, then I would need to check if they were readable by the WASM and provide a mechanism to pass the values back to FSUIPC as I do with lvars. But I can't really say much more until I know more about what z:vars are and how they can be accessed. I don't see anything about these in the MSFS SDK documentation - do you have any references? John
joeherwig Posted October 22, 2022 Report Posted October 22, 2022 @John Dowson it seems that ZVars really behave like the AVars. A friend from german flight simulator club succeded to utilize them using calculator codes. Quote -- $$ Map function LX_9050_map_scroll_west () ipc.execCalcCode("(Z:B21_LX_9050_BUTTON_8_TOGGLE) 0 > if{ 0 (>Z:B21_LX_9050_BUTTON_8_TOGGLE) } els{ 1 (>Z:B21_LX_9050_BUTTON_8_TOGGLE) }") ipc.execCalcCode("(Z:B21_LX_9050_BUTTON_8,number) 0 == if{ 100 (>Z:B21_LX_9050_BUTTON_8, number) } els{ 0 (>Z:B21_LX_9050_BUTTON_8, number) }") ipc.execCalcCode("(L:SOUND_CLICK) 0 == if{ 1 (>L:SOUND_CLICK) } els{ 0 (>L:SOUND_CLICK) }") end function LX_9050_map_scroll_east () ipc.execCalcCode("(Z:B21_LX_9050_BUTTON_7_TOGGLE) 0 > if{ 0 (>Z:B21_LX_9050_BUTTON_7_TOGGLE) } els{ 1 (>Z:B21_LX_9050_BUTTON_7_TOGGLE) }") ipc.execCalcCode("(Z:B21_LX_9050_BUTTON_7,number) 0 == if{ 100 (>Z:B21_LX_9050_BUTTON_7, number) } els{ 0 (>Z:B21_LX_9050_BUTTON_7, number) }") ipc.execCalcCode("(L:SOUND_CLICK) 0 == if{ 1 (>L:SOUND_CLICK) } els{ 0 (>L:SOUND_CLICK) }") end function LX_9050_map_scroll_north () ipc.execCalcCode("(Z:B21_LX_9050_BUTTON_2_TOGGLE) 0 > if{ 0 (>Z:B21_LX_9050_BUTTON_2_TOGGLE) } els{ 1 (>Z:B21_LX_9050_BUTTON_2_TOGGLE) }") ipc.execCalcCode("(Z:B21_LX_9050_BUTTON_2,number) 0 == if{ 100 (>Z:B21_LX_9050_BUTTON_2, number) } els{ 0 (>Z:B21_LX_9050_BUTTON_2, number) }") ipc.execCalcCode("(L:SOUND_CLICK) 0 == if{ 1 (>L:SOUND_CLICK) } els{ 0 (>L:SOUND_CLICK) }") end function LX_9050_map_scroll_south () ipc.execCalcCode("(Z:B21_LX_9050_BUTTON_5_TOGGLE) 0 > if{ 0 (>Z:B21_LX_9050_BUTTON_5_TOGGLE) } els{ 1 (>Z:B21_LX_9050_BUTTON_5_TOGGLE) }") ipc.execCalcCode("(Z:B21_LX_9050_BUTTON_5,number) 0 == if{ 100 (>Z:B21_LX_9050_BUTTON_5, number) } els{ 0 (>Z:B21_LX_9050_BUTTON_5, number) }") ipc.execCalcCode("(L:SOUND_CLICK) 0 == if{ 1 (>L:SOUND_CLICK) } els{ 0 (>L:SOUND_CLICK) }") end So obviously they already can be utilized. No need for change imho.
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