Jump to content
The simFlight Network Forums

LUA Libraries...


Recommended Posts

Hi - many thanks for FSUIPC, which I've just purchased after using the demo mode for some time.

I have decided to create some hardware interfaces, starting with simple Autopilot buttons and selectors and hopefully moving up to a Radio Stack, etc....I've ordered an Arduino Mega to facilitate this and was going to use Lua for the programming language.

In the meantime Ive started to prototype with a digital on screen version, but I've been having some trouble with libraries.

I've tried creating a simple dialog box with progress bar and some buttons (standard Windows style) using the IUP library, but I can't even get the library itself to load.

Is it even possible to create a Glass Cockpit type of situation using FSUIPC and Lua? The documentation refers to loading other lua libraries, but nothing seems to work.

I've spent hours trying files in different folders.....what the hell am I missing!!

Link to comment
Share on other sites

I've tried creating a simple dialog box with progress bar and some buttons (standard Windows style) using the IUP library, but I can't even get the library itself to load.

I'm not familiar with that library.

Is it even possible to create a Glass Cockpit type of situation using FSUIPC and Lua?

Well I wouldn't have thought it was easy. You'd probably need to run FS in windowed mode, not full screen.

The documentation refers to loading other lua libraries, but nothing seems to work.

There are quite a lot of existing FSUIPC Lua applications which are using external libraries. If they are DLLs, in older versions of FSUIPC you had to put those libraries into the main FS folder, but now they are okay in a DLL subfolder within the Modules folder. For Lua-written libraries you can put them in a Lua subfolder, or in the Modules folder. Whichever you choose you have to do a "require" call to load them.

I've spent hours trying files in different folders.....what the hell am I missing!!

Sorry, I've no idea. You've provided no information to go on. Have you tried looking at the Log, even enabling the debug option on the Logging tab inFSUIPC?

If you are not using an up to date version of FSUIPC (e.g. 4.852 fr FSX), then the first stepis to update.

Regards

Pete

Link to comment
Share on other sites

Hi Pete - sorry for the lack of information yesterday....I was tired and due my meds and was a little ratty.

Here's the log from the Lua script....this is one using GD which is recommended in your Lua documentation...

********* LUA: "GlassCockpit" Log [from FSUIPC version 4.852] *********

22449 System time = 04/09/2012 14:43:31, Simulator time = 14:43:12 (21:43Z)

22449 LUA: beginning "F:\Microsoft Flight Simulator X\Modules\GlassCockpit.lua"

22449 *** LUA Error: ...icrosoft Flight Simulator X\Modules\GlassCockpit.lua:1: module 'gd' not found:

no field package.preload['gd']gd

no file 'F:\Microsoft Flight Simulator X\modules\gd.lua'

no file 'F:\Microsoft Flight Simulator X\modules\gd\init.lua'

no file 'F:\Microsoft Flight Simulator X\modules\lua\gd.lua'

no file 'F:\Microsoft Flight Simulator X\modules\lua\gd\init.lua'

no file 'D:\Program Files (x86)\Lua\5.1\lua\gd.luac'

no file 'F:\Microsoft Flight Simulator X\modules\lua\gd.dll'

no file 'F:\Microsoft Flight Simulator X\modules\lua\loadall.dll'

22449 LUA: ended "F:\Microsoft Flight Simulator X\Modules\GlassCockpit.lua"

22449 System time = 04/09/2012 14:43:31, Simulator time = 14:43:12 (21:43Z)

********* LUA execution terminated: Log Closed *********

I've tried leaving them in the windows environment var location specified in the LUa for Windows install, I've have tried creating a DLL folder, and creating a Lua folde both under the FSX/Modules directory and it does the same every time. The particular line where it says it can't find gd.dll is an outright lie as it's sitting right in the Lua folder its looking in.

These require references work in the Lua for windows development environment....so, lets turn it around...........I can make a standalone Lua scripted .exe that will use the additional libs I need to create my display and Arduino interface, but what about the FSUIPC library? How do I include that into my Lua for Windows development environment so it doesn't fall over at the first ipc. it comes across? If I create a standalone version then it can run via WideFS on a second machine, yes?

By the way, I'm using the latest version from your website after purchasing FSUIPC as I thought that might solve the problem, but it's not.

Any help would be gratefully appriciate so I haven't wasted my £35.

Edited by Leo Morse
Link to comment
Share on other sites

Make sure you don't have two files with the same name but a different extension, I noticed something odd like this with LINDA last week, I was having problems with Linda loading and Artem informed me from the log I sent him it appeared as if a script was being loaded twice. For example I had a couple of files named similar to the below in the same folder;

Fallback.lua

Fallback.lua.org

When updating files I always leave the original file in place and simply rename it .org until I'm sure the new one works properly. When I did this recently with one of Linda's lua's it caused an error with an almost identical error in the log to yours Leo. Try moving any duplicate back up files like mentioned above to a completely different place and see if that helps.

Link to comment
Share on other sites

I've tried leaving them in the windows environment var location specified in the LUa for Windows install, I've have tried creating a DLL folder, and creating a Lua folde both under the FSX/Modules directory and it does the same every time. The particular line where it says it can't find gd.dll is an outright lie as it's sitting right in the Lua folder its looking in.

As I said, I think DLL libraries need to be in a DLL subfolder in Modules. The Lua subfolder is for Lua libraries (i.e. libraries written in Lua).

These require references work in the Lua for windows development environment....so, lets turn it around...........I can make a standalone Lua scripted .exe that will use the additional libs I need to create my display and Arduino interface, but what about the FSUIPC library? How do I include that into my Lua for Windows development environment so it doesn't fall over at the first ipc. it comes across? If I create a standalone version then it can run via WideFS on a second machine, yes?

You are really getting way beyond my knowledge of Lua mechanics. I only know that a number of developments using both Lua and DLL libraries have already been constructed and working well. Recommendations or links to libraries which can be used have been provided by users. I am not one of these at all. I support Lua in FSUIPC so that these other folks, cleverer than I, can do such clever things.

Any help would be gratefully appriciate so I haven't wasted my £35.

:sad:

I think that's a bit of a nasty and cheeky comment. I provide Lua support in FSUIPC and it is being well used and is much appreciated, but I cannot support the Lua environment itself, only the code I know in FSUIPC. The package which is embedded, and which I do not know as well, is described mainly on the Lua website and in the several books published on the subject. I suggest you learn more about Lua if you aren't currently able to make it do what you want as well as others have done.

Pete

Link to comment
Share on other sites

Pete, no cheek or nastiness intended....I'm just getting frustrated at getting nowhere. I do appriciate your work in FSUIPC, and I'm not asking for support for my Lua environment, just help with the FSUIPC libraries and running Lua scripts within FSUIPC.

In your SDK, you provide Libaries for many languages such as C, C#, Java, etc.....is there one for Lua? If so, I could just install the IPC lib in the LUA Development Environment, do the coding there with FSUIPC and FSX running to supply the interface variables, get debugging info right inside the environment and then create a standalone compiled EXE for there that runs alongside FSX with FSUIPC and produces the gauges.

I only know that a number of developments using both Lua and DLL libraries have already been constructed and working well.

Can you provide a link to these so I can break down their code to see where I'm going wrong?

Link to comment
Share on other sites

In your SDK, you provide Libaries for many languages such as C, C#, Java, etc.....is there one for Lua?

Those are libraries implementing the memory-mapping interface into FSUIPC for applications wishing to get data into and out of FS. The Lua support has much closer in-process integration already, provided in the ipc built-in Lua library. That was the whole point of adding the Lua support in that way.

If you wish to use Lua as an application programming language as opposed to a plug-in scripting system then you would need to take the source of the C-library (in the SDK) and build a DLL with the appropriate Lua hooks in it. This is not part of the plug-in system I've provided of course. If you do that you'd be interfacing into FS as a separate process, and you would not need to have spent your £35 because the interface into FS is free for non-commercial applications.

Can you provide a link to these so I can break down their code to see where I'm going wrong?

You mean others using DLL libraries? Browse the User Contributions subforum for a start, or search for folks using the mentioned DLLs with FS. One's which come to mind are the OzRunways interface recentlly subject of a thread here, maybe LINDA, and the one I don't recall the name of which is using a graphics DLL to draw gauges on the Saitek modules. I'm afraid I don't have direct references to any, but a number like this have occurred over the years.

Have you tried simply putting your DLL into a DLL subfolder in the Modules folder?

Pete

Link to comment
Share on other sites

Did you miss my earlier post or are you both just ignoring me, lol. It could just be a simple bug.

Hi Andy.

No, I'm not ignoring you. I thought you were aiming your suggestion at the OP. I really wouldn't know why you'd get an error from having those two files there, at least not without delving deep into the original Lua interpreter code, much of which is rather obscure to my aging eyes!

Regards

Pete

Link to comment
Share on other sites

I just thought it was strange that neither yourself or Leo said anything at all in reply to my post, because doing what I suggested takes no time at all to confirm. Basically it seems the lua interpreter doesn't really read any further than .lua when seeing a file name and ignores whatever comes after it. Either that or it's something strange in Artems implementation of LINDA.

Link to comment
Share on other sites

I've noticed, in the "pokeys-device-lua-script-external-dll-using-luacom" thread in User Contribution, that it succeeds using a DLL in the Lua subfolder of Modules, but it also needs the main Lua 5.1 DLL installed in the main FS folder. I assume that Lua DLLs which themselves make calls into Lua libraries will need the external Lua libraries, because there is no way back into those built into FSUIPC.

It would have been nice and tidy if I could have found a way for external DLLs to use the Lua libraries built in, but there was really no way, as they'll be linking directly into Lua itself. The Lua scrpt files are okay of course because they are loaded and executed by the built-in interpreter.

Pete

Link to comment
Share on other sites

Did you miss my earlier post or are you both just ignoring me, lol. It could just be a simple bug.

Sorry, I did check this but forgot to reply - it wasn't the case with my set up.

I tried some other libs in the FSUIPC folders but they either threw out the same field package error, or crashed FSX altogether when declaring the simple require command.

Using the OzRunways script I've managed to get a script running under FSUIPC to send data to another external script so I think this will solve the problem, and also make the connection possible across multiple machines too, so now I can have a standalone app running all the libs I want without having to worry about compatibility with FSUIPC and FSX.

Regardless of if I needed the full paid-for app or not, if I find any Shareware app useful, I will pay for it....simple as that! Without people paying for the things they use, people won't spend time making the things people need/want.

Link to comment
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...
 Share

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