Jump to content
The simFlight Network Forums

Kuro B787-8 Accessing indexed Lvars via Lua Script


Airbuspilot

Recommended Posts

Hello,

maybe my Question is stupid, but i stuck at the following Problem.
There are 2 Lvars named: B787_IRS_KNOB_STATE:1 and B787_IRS_KNOB_STATE:2

For me it seems, that the Variable is indexed and i don't have any Idea, how to set them
from 0 to 1 and back. Could someone please explain, what i have to code?

Thanks in Advance, Joachim

Link to comment
Share on other sites

32 minutes ago, Airbuspilot said:

There are 2 Lvars named: B787_IRS_KNOB_STATE:1 and B787_IRS_KNOB_STATE:2

For me it seems, that the Variable is indexed and i don't have any Idea, how to set them
from 0 to 1 and back. Could someone please explain, what i have to code?

That is interesting - I didn't know that lvars could be indexed....
If you list the lvars (Add-ons->WASM->List Lvars) do you see them individually (as indexed)  or just see B787_IRS_KNOB_STATE?
In the case of the former, you can just use the ipc.writeLvar function.  In the case of the latter, you can try with the ipc.execCalcCode function, e.g.
    ipc.execCalcCode("0 (> B787_IRS_KNOB_STATE:1)")
    ipc.execCalcCode("1 (> B787_IRS_KNOB_STATE:1)")

    ipc.execCalcCode("0 (> B787_IRS_KNOB_STATE:2)")
    ipc.execCalcCode("1 (> B787_IRS_KNOB_STATE:2)")

John

 

Link to comment
Share on other sites

1 hour ago, Airbuspilot said:

for me it looks, like they were indexed.
image.png.af4fbdb3573d4a47823e7da652237996.png

So, i use the ipc.execCalcCode Method.

If they are listed like that, then they are just individual lvars as far as FSUIPC is concerned and you can use either method.
Btw, why are you using the WASMClient? You can do everything this app does directly in FSUIPC using the Add-ons->WASM menu.

Cheers,

John

 

Link to comment
Share on other sites

22 hours ago, John Dowson said:

If they are listed like that, then they are just individual lvars as far as FSUIPC is concerned and you can use either method.
Btw, why are you using the WASMClient? You can do everything this app does directly in FSUIPC using the Add-ons->WASM menu.

Cheers,

John

 

Hey John,

setting them with the execCalcCode Method works fine in this Case.
But for Learning Purposes, could you please show the necessary Code to set them with the ipc.writeLvar Method?
Why i used the Client in this Case i don't know. Normally i use the Functions in the FSUIPC Menu.

Meanwhile i have another Problem and i hope, you can help me out please.
If i set the Battery Switch with the Set Lvars in the FSUIPC Menu, the Switch will work like he should work.
If i use this Code
    ipc.writeLvar("L:XMLVAR_BATTERY_SWITCH_STATE", 1)
in my Lua Script, nothing happens. Do you have any Hint for me, what i have to do, to get this Code to work?

Thanks a Lot in Advance
Joachim

Link to comment
Share on other sites

1 hour ago, Airbuspilot said:

But for Learning Purposes, could you please show the necessary Code to set them with the ipc.writeLvar Method?

It is just
    ipc.writeLvar("B787_IRS_KNOB_STATE:1", 0)
    ipc.writeLvar("B787_IRS_KNOB_STATE:1", 1)
    ipc.writeLvar("B787_IRS_KNOB_STATE:2", 0)
    ipc.writeLvar("B787_IRS_KNOB_STATE:2", 1)
 

1 hour ago, Airbuspilot said:

If i use this Code
    ipc.writeLvar("L:XMLVAR_BATTERY_SWITCH_STATE", 1)
in my Lua Script, nothing happens. Do you have any Hint for me, what i have to do, to get this Code to work?

That should work. Note that you need to wait for a short period after the aircraft is loaded for lvars to be available. If it is not working, set WAPI Debug level logging (Log->WAPI->Debug) as well as lua plugin logging (Log->Lua Plugins) and Log->Buttons & Keys - no other logging please - and generate a log file showing your issue, and then attach your FSUIPC7.log file together with your FSUIPC7.ini file and lua script and I can take a look.

Link to comment
Share on other sites

First of all - Thank you for helping me with that Problems.

Attached yo will find:
FlightLog.lua - The Script with the wanted Functions
FlightLog.log - The Log File from the last Session

And the Files from FSUIPC.
Hope, you can find a Solution. If you need further Information or Files, please let me know.

Thanks a Lot in Advance
Joachim 

FSUIPC7.log FlightLog.log FlightLog.lua FSUIPC7.ini

Link to comment
Share on other sites

Why did you log lua files separately? I specifically asked you for no other logging options other than the ones I specified as I did not want to see a separate log file for your lua script. It is far easier for me to tell what is happening if I can see just the one log file...

I will take a look at these tomorrow now...

John

 

Link to comment
Share on other sites

Unfortunately your log files aren't showing me much. Looks like you didn't activate WAPI debug logging until after you activated your lua script.
Can you provide me with a fresh set of files please, this time with the lua logged in the FSUIPC7.log file and not in a separate file. Also, could you set Debug level logging in the WASM and show me your WASM log file as well - see the Advanced User guide (WASM section) on how to do this and where the WASM .log and .ini files are located.

If you have Lua Plugin logging enabled, you can start the script with just Lua and not LuaDebug.

Also, if your issue is just with the ipc.writeLvar function, it would be easier to see what is happening if you just has a simple lua script with these calls for test purposes, which can be started on a button or key press.

Link to comment
Share on other sites

Not sure why the lua isn't being logged - do you have logging for Lua Plugins activated? The only lua logging I see is this (and why FlightLog.lua and not FlightLogJohn.lua? Please keep file names as they are) :

Quote

   239547 LUA.1: beginning "D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua"

However, your WASM log file does show that the lvar was updated:

Quote

Sun Aug 20 16:44:49 2023   [DEBUG]: EVENT_LVARSET_REQUEST_RECEIVED: lvarId='95', param=1.000000
Sun Aug 20 16:44:49 2023   [DEBUG]: Lvar with id=95 set to 1.000000

Presumably the lvar with id 95 is L:XMLVAR_BATTERY_SWITCH_STATE (please check this by listing the lvars), and this is from this call:

Quote

    ipc.writeLvar("L:XMLVAR_BATTERY_SWITCH_STATE", 1)

So the ipc.writeLvar call is working as  expected....unless its getting the wrong id got some reason,..

John

Link to comment
Share on other sites

2 hours ago, Airbuspilot said:

This Time I've done it with my own FlightLog.lua.

Ah...in that case I am not sure which lvar was updated - especially as the lua wasn't logged...

The WAPI should log the lvar update requests in the FSUIPC7.log file, but it looks like this may only happen at the TRACE logging level. I will change this.

2 hours ago, Airbuspilot said:

If i should use the small File created for you, please let me know.

Yes please...

Could you also make sure that you have exited FSUIPC7 before attaching log files. And check them yourself before posting - no point attaching if the lua script isn't being logged.
Basically any call to ipc.writeLvar should have a corresponding message in the WASM log, and also in the WAPI log, or an error.

Also, are you sure the lvars you are using actually exist? Initially, you get 430 lvars:

Quote

Sun Aug 20 16:44:16 2023    [INFO]: 430 lvars loaded for aircraft 'B788 DLH D-ABNA'

You set one, byt then 431 are detected:

Quote

Sun Aug 20 16:44:49 2023   [DEBUG]: EVENT_LVARSET_REQUEST_RECEIVED: lvarId='95', param=1.000000
Sun Aug 20 16:44:49 2023   [DEBUG]: Lvar with id=95 set to 1.000000
Sun Aug 20 16:44:52 2023    [INFO]: New lvars detected: 431 lvars detected (was 430): reloading...

and then when you set lvars using calculator code (which will create them if they don't exist) another 4 more are found:

Quote

Sun Aug 20 16:44:54 2023   [DEBUG]: Calculator code executed: '1 (>L:EXT_PWR_COMMANDED:1)'
Sun Aug 20 16:44:54 2023   [DEBUG]: Calculator code executed: '1 (>L:EXT_PWR_COMMANDED:2)'
Sun Aug 20 16:44:54 2023   [DEBUG]: Calculator code executed: '1 (>L:EXT_PWR_COMMANDED:3)'
Sun Aug 20 16:44:54 2023   [DEBUG]: Calculator code executed: '1 (>L:B787_IRS_KNOB_STATE:1)'
Sun Aug 20 16:44:54 2023   [DEBUG]: Calculator code executed: '1 (>L:B787_IRS_KNOB_STATE:2)'
Sun Aug 20 16:44:56 2023    [INFO]: New lvars detected: 435 lvars detected (was 431): reloading...

Next time you test, can you list the lvars (Add-ons->WASM->List Lvars) both before and after you press the button that starts the lua script, so  I can see the lvars available.

Thanks,

John

Link to comment
Share on other sites

Also can you try with the following version, which has extra WAPI debug logging added, so you should now see the lvar update request sent in the FSUIPC7 log file. With this and lua plugin logging enabled, you should see what is happening, e.g. here's a log extract from a simple lua script that first writes 1 to a couple of lvars, then 0, then 1 again:

Quote

   ...
   250156 LUA.3: beginning "D:\FSUIPC7\Lua\lvarTest.lua"
   250156 LUA.3: D:\FSUIPC7\Lua\lvarTest.lua:1
   250171 LUA.3: Global: ipcPARAM = 0
   250187  [DEBUG]: Lvar update request sent via CDA: id=736, value=1.000000
   250203 LUA.3: D:\FSUIPC7\Lua\lvarTest.lua:2
   250218  [DEBUG]: Lvar update request sent via CDA: id=737, value=1.000000
   250234 LUA.3: D:\FSUIPC7\Lua\lvarTest.lua:3
   250265  [DEBUG]: Flagging lvar for callback: id=736
   250296  [DEBUG]: Flagging lvar for callback: id=737
   251265 LUA.3: D:\FSUIPC7\Lua\lvarTest.lua:4
   251265  [DEBUG]: Lvar update request sent via CDA: id=736, value=0.000000
   251281 LUA.3: D:\FSUIPC7\Lua\lvarTest.lua:5
   251296  [DEBUG]: Lvar update request sent via CDA: id=737, value=0.000000
   251312 LUA.3: D:\FSUIPC7\Lua\lvarTest.lua:6
   251343  [DEBUG]: Flagging lvar for callback: id=736
   251375  [DEBUG]: Flagging lvar for callback: id=737
   252343 LUA.3: D:\FSUIPC7\Lua\lvarTest.lua:7
   252343  [DEBUG]: Lvar update request sent via CDA: id=736, value=1.000000
   252359 LUA.3: D:\FSUIPC7\Lua\lvarTest.lua:8
   252375  [DEBUG]: Lvar update request sent via CDA: id=737, value=1.000000
   252421  [DEBUG]: Flagging lvar for callback: id=736
   252437  [DEBUG]: Flagging lvar for callback: id=737
   ...

John

FSUIPC7.exe

Link to comment
Share on other sites

Used the new FSUIPC7.exe File.
What i see in the WASMIF.log is, that the LVar exists with a Value of 0 before and after starting the small FlightLog.lua.
In the FSUIPC7.log is to see that the Line of Code will be executed.

In the Wasm.log i can't see anything, that i could understand.
I attached all the Files, so that you could take a Look by yourself if you want to.

Here is a Pic from the lua File. So you can see, whats happening, when the File was executed.
image.thumb.png.fa5e9f919f18837cf9cce57ea0cf4f03.png

FSUIPC_WASM.log FSUIPC_WASMIF_after_Start_FlightLog.log FSUIPC_WASMIF_before_Start_FlightLog.log FSUIPC7.log

Link to comment
Share on other sites

Why are you attaching pictures instead of files? Why do you have a separate FSUIPC_WASMIF.log file, instead of using the default and having everything logged just to the FSUIPC7.log file?

I am not going to look at those files. Please supply just two log files, the FSUIPC7.log file, generated containing the WAPI debug information,  lua plugin logging and Button & Key logging (maybe also Event logging, but probably not necessary), and the FSUIPC_WASM.log file. Also attach your FSYUPC7.ini and the *.lua file you are using.

And please check the log file before posting - it should contain both lua logging and WAPI debug logging. If it doesn't, no point posting it as I will just ask again...

This really isn't that difficult - you seem to be over-complicating things... 

Link to comment
Share on other sites

I took al look at that last FSUIPC7.log file and it shows:

Quote

   ... 
   246906 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:3
   246922 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:5
   246938 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:12
   246969 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:3
   246985 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:5
   247000 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:12
   247031 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:3
   247047 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:5
   247063 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:12
   247094 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:3
   247110 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:5
   247125 LUA.1: D:\Simulatoren\MSFSaddons\FSUIPC\FlightLog.lua:12
  ...

What lua file is that? It doesn't correspond to any lua file that you shown me so far...

I guess the WASMIF.log files are from you using the WASMClient, no? Why are you using that? As I said, please use the FSUIPC7 facilities (Add-ons->WASM->List Lvars) and get everything logged to the same FSUIPC7.log file.... 

Link to comment
Share on other sites

Sorry, i have to deeply apologize.
I found the Solution by my self. In the Code, i didn't pay Attention to the Capitals in Lvar Names.
When writing them in the correct Way, everything works fine.
Thank you very much for your attempts to help.

BTW: If possible, i avoid to use the WASM. Whether the Client nor the FSUIPC Functions.
I have a serious Eye Sickness and i need a dark Background with white/yellow Foreground.
Also i need a bigger Font. So i prefer to use the SPAD.next and therefore i am not so familiar with the WASM.

Is there any Chance, to get this in the WASM too?

Joachim

Link to comment
Share on other sites

2 minutes ago, Airbuspilot said:

I found the Solution by my self. In the Code, i didn't pay Attention to the Capitals in Lvar Names.
When writing them in the correct Way, everything works fine.

Ah, ok....

3 minutes ago, Airbuspilot said:

Is there any Chance, to get this in the WASM too?

Sorry, but what do you mean by this?

Link to comment
Share on other sites

On 8/22/2023 at 10:32 AM, John Dowson said:

Sorry, but what do you mean by this?

In the Facilities of the WASM, reachable over the FSUIPC Add-ons Menu, i.E. the Lvar List. should be a dark Background and a white/yellow Foreground. Also a bigger Font in the Whole FSUIPC UI and of Course in the WASM Panels would be highly appreciated. In all the Lvars Functions in the WASM should be a Search Function for Lvar Names or Fragments of them. In my Opinion, all those Changes will raise the Usability of the whole FSUIPC Experience.

I know, that Developers couldn't realize any Wish of one or some more Users. But maybe you see a Chance, to realize it.
If you need further Informations, please let me know.

Joachim  

Link to comment
Share on other sites

I can look into the possibility of allowing the font size to be uncreased, and allow light text on a dark background. I will add this to my to-investigate list, although I have no idea when I will have time to look into this at the moment. Unfortunately all my time is taken up by support these days and I have little time for adding new features.
I will not be adding a search function for lvars - you can just list the lvars, open the FSUIPC7.log file in an editor and use the editors search facilities. Not also that the logging console window is light text on a dark background, and lvars are also listed there (it it just a window onto the FSUIPC7.log file), so you can try opening that (Log->Open Console) and using that.

John

Link to comment
Share on other sites

Okay, i didn't know, that my wished Features are that much to do for you.
So i will further use the SPAD.next for my Work with Lvars. There is everything in one Place without the Hassle of investigating Log Files or editing Values in a tiny Window. You don't have the Time and if there are no other Users finding my Wishes helpful, please forget my Ask.
Thanks for the Help in this Thread, that could be marked as solved.

Joachim

 

Link to comment
Share on other sites

13 minutes ago, Airbuspilot said:

i didn't know, that my wished Features are that much to do for you.

I don't know why you say this... I have a long list of user requests and I process and implement them as time permits...unfortunately, most of my time is taken up by support requests, which take priority. 

I also have an issue with my eyes - I have a genetic degenerative eye disease (Retinitis pigmentosa -RP) so I am certainly willing to improve the visual aspects of the software I provide, but there are only so many hours in a day and I have to prioritise, which doesn't leave me much time. If I could only spend less time on support questions, especially those that could be answered if people actually consulted the documentation I provide and used the resources available before posting questions.... this would save me a lot of time and I would have more time available to implement such features...

25 minutes ago, Airbuspilot said:

So i will further use the SPAD.next for my Work with Lvars.

That is, of course, up to you. SPAD.next is also a great tool - I also use this occasionally. But it doesn't provide the power and control that you can get with FSUIPC, but is generally easier to use for novice users.

30 minutes ago, Airbuspilot said:

Thanks for the Help in this Thread, that could be marked as solved.

I don't mark threads as solved - they need to be open if someone has a similar issue that they need to discuss.

Regards,

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.