Jump to content
The simFlight Network Forums

Lua development with FSUIPC


Recommended Posts

I am hoping to get some guidance in writing & testing lua programs with FSUIPC. I am a retired programmer, built a GA cockpit 4 years ago. Environment is Win 7, FSX, FSUIPC4 ver 4.937 (registered), Lua 5.1, SciTE editor. I have read the FSUIPC documents re Lua several times, but cannot figure out what I am missing. I tested a couple lua scripts (gfdDisplay & display vals) with FSX & they ran fine, produced expected results. I am a beginner with respect to Lua, my question is where are the 10 lua libraries that come with FSUIPC4? Are they part of FSUIPC4.DLL? For writing a lua program, should this module be copied to lua\clib? Then to test a lua module, I presume it has to be run with FSX. When trying to run a lua script by itself, I get the error "attempt to index global 'ipc' (a nil value)".

 

I would appreciate some comment, am I on the right track or really missing something? I decided to try the Lua route because some of my GoFlight modules do not work with the A2A 172. Thanks for any help.

Gene

Link to comment
Share on other sites

I am hoping to get some guidance in writing & testing lua programs with FSUIPC. I am a retired programmer, built a GA cockpit 4 years ago. Environment is Win 7, FSX, FSUIPC4 ver 4.937 (registered), Lua 5.1, SciTE editor. I have read the FSUIPC documents re Lua several times, but cannot figure out what I am missing. I tested a couple lua scripts (gfdDisplay & display vals) with FSX & they ran fine, produced expected results. I am a beginner with respect to Lua, my question is where are the 10 lua libraries that come with FSUIPC4? Are they part of FSUIPC4.DLL?

 

Yes, almost* the libraries listed in the FSUIPC Lua documentation are built in, as are the standard Lua libraries like string, math and so on. You do not need to "Require" them. I thought it was pretty clear in the documentation.

 

* The exceptions are those which are marked "WideClient only". Wideclient also has most of the libraries, for use in Lua plug-ins on WideFS client PCs -- it doesn't have a couple but also has ones not included in FSUIPC. But it too has the standard Lua libraries as documented in Lua books and on their website.

 

For writing a lua program, should this module be copied to lua\clib? Then to test a lua module, I presume it has to be run with FSX. When trying to run a lua script by itself, I get the error "attempt to index global 'ipc' (a nil value)".

 

FSUIPC always stays in the FS Modules library, and is only active when FS is running as it is part of FS then. FS only sees Lua plug-ins which are placed in the Modules folder too. All this is surely very clear in the documentation?

 

I don't know anything about a "clib" folder. This must be something you are doing by yourself. You CAN load Lua plug-ins from other folders, but you'd need to do this with the ipc.runlua function giving the fpath, in an already loaded plug-in.

 

Unless you are trying to do something with other, specialist, Lua libraries downloaded from other sites, you need nothing but your plug-in and FSUIPC running.

 

Pete

Link to comment
Share on other sites

Pete,

Thank you for the prompt reply. I do understand that FSUIPC and lua scripts have to be in the modules folder to run with FS. What I did not understand is that FS has to be running in order to write a lua program. However I see the logic of it and understand now. I guess my background of writing software in an editor, syntax checking, basic logic, etc, then plugging the result into another system for test had me headed down the wrong track. I had done a search in this forum for “lua” and found 85 threads. I will now go back through them & see if I can learn anything else.

 

“Clibs” is a folder created by the Lua install package, & contains other libraries.

Gene

Link to comment
Share on other sites

What I did not understand is that FS has to be running in order to write a lua program.

 

No, not to write one. You only need an editor for that. Obviously, because the Lua program is just a plug-in for FS, enabled by FSUIPC, without FS it can do nothing. What could you expect it to be able to do, when the whole point is to interact with FS?

 

I guess my background of writing software in an editor, syntax checking, basic logic, etc, then plugging the result into another system for test had me headed down the wrong track.

 

But that's exactly what you'd do with Lua plug-ins, although you don't need two systems if you can run FS on the same system as your editor.

 

I had done a search in this forum for “lua” and found 85 threads. I will now go back through them & see if I can learn anything else.

 

 

There are lots of examples provided in the FSUIPC Documents Lua package, as listed in the documentation, and other folks have posted theirs in the User Contributions subforum. But I learned Lua from the Lua programming books published and easily available.

 

Pete

Link to comment
Share on other sites

 What I did not understand is that FS has to be running in order to write a lua program.

 Unless you are doing something quite unique that I don't understand, you can certainly use a text editor, like Notepad++, or LuaEdit, to write a Lua program without FSX running and then save the program into the Modules folder.

Al

 

Edit:  Sorry -- didn't see Pete's response as I was writing this.

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.