Jump to content
The simFlight Network Forums

Using LUA -> some questions


Recommended Posts

Hi Pete,

I only recently noticed that you have added a LUA based add-on system for FSUIPC. At first sight this seems to have great potential...

I'm not very familiar with LUA and before I get involved I have a few questions:

- Do I understand correctly that for the user to be able to access any LUA add-on he/she needs to have a registered version of FSUIPC ?

- If I was to include a (pre-compiled) LUA module with my add-on airplane, is there any way this module can be loaded automatically without intervention from the user, I tried calling one of the demo module "ipcInit.lua" but that wasn't the solution.

- Are LUA applications (if you can call them "applications") running in a separate thread or inside the main FS thread ? In other words, would doing calculations like for instance for INS navigation give me better FPS ?

- Can you confirm that through LUA I only have access to the FSUIPC interphase, no direct access to FS variables or customs XML variables? So if I want to communicate between a LUA add-on and my gauge in FSX (for instance my gauge has to let the module know if the HDG mode of the autopilot is engaged) I would need to use some of the unused offsets available in FSUIPC as a means of connecting both?

Kind regards,

Björn

Link to comment
Share on other sites

I only recently noticed that you have added a LUA based add-on system for FSUIPC.

Yes, nearly a year ago.

- Do I understand correctly that for the user to be able to access any LUA add-on he/she needs to have a registered version of FSUIPC ?

Yes.

- If I was to include a (pre-compiled) LUA module with my add-on airplane, is there any way this module can be loaded automatically without intervention from the user, I tried calling one of the demo module "ipcInit.lua" but that wasn't the solution.

The Lua files "ipcInit.lua" and "ipcReady.lua" are run automatically, the former early, when FSUIPC is first loaded and before the rest of FS is ready to fly, the latter when ready to fly. I'm not sure what you mean by 'calling one of the demo module "ipcInit.lua'", there's no such demo, it is the fixed name for an auto-run plug-in. If all yuo are doing is providing additional or specialised controls for your aircraft, the Lua module only need to be in the FS Modules folder. The user would then assign buttons or keypresses to it. If you want it to be running all the time then it would need to be instigated by the ipcInit or ipcReady modules, or you could request FSUIPC to load it in your code through the relevant FSUIPC offsets.

- Are LUA applications (if you can call them "applications") running in a separate thread or inside the main FS thread ? In other words, would doing calculations like for instance for INS navigation give me better FPS ?

Each Lua module runs in its own thread. Whether this gives you better performance or not I couldn't say. You'd need to try it. FSUIPC does force the threads to yield between each Lua statement, in case other essential tasks are running in the same core.

- Can you confirm that through LUA I only have access to the FSUIPC interphase, no direct access to FS variables or customs XML variables? So if I want to communicate between a LUA add-on and my gauge in FSX (for instance my gauge has to let the module know if the HDG mode of the autopilot is engaged) I would need to use some of the unused offsets available in FSUIPC as a means of connecting both?

What is "direct access to FS variables"? Do you mean SimConnect variables? If so, no, there's no direct interface to SimConnect, though, in fact, that would be easy enough to add, at least for reading named SimVars. I just never thought of it. I suppose I could allow writing to them too, returning the error should one occur, though the problem then is the asynchronous nature of the responses -- you get no "ok" response so you don't know when to allow the Lua program to continue.

If you look through the Lua documentation provided you will see that for FSUIPC4 (FSX and ESP) there are facilities for reading and writing L:variables, which I believe are the named values used in XML gauges. There's even a sample program provided to list their values on screen and in the Log. Have you not yet perused any of the supplied documentation?

Either way, please do NOT "unused offsets". There's really no such thing, or at least not in a way you can tell. If you need any for your own local and private purposes use those allocated for that at 66C0. Otherwise please apply for an allocation, to avoid clashes with other add-ons.

Regards

Pete

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.