Jump to content
The simFlight Network Forums

How can we develop with lua more efficiently?


Recommended Posts

Hello fellow simmers!

 

I've been using lua in my FSX projects for some time now, and I love it. Simple yet powerful. Thank you Pete for implementing lua in fsuipc.

 

But I can't really find a way to develop with it efficiently.

 

While developing I often bind the lua scripts to be executed by key presses (often the numeric keys). And I use tail to keep an eye on the log file.

 

This approach works but it feels a bit clumsy.

 

Is there a better way of doing this?

 

How do you develop? Do you have any tips, ideas or suggestions how one can develop more efficiently?

 

Any thoughts on this Pete Dowson (or anyone)?

Link to comment
Share on other sites

But I can't really find a way to develop with it efficiently.

 

If it's the Lua language itself you are talking about, there are some excellent books on it.  Try, in order:

 

"Beginning Lua Programming" by Jung & Brown, pub Wiley 2006

"Programming in Lua" by Ierusalimschy, pub by Lua.org (maybe available on-line?)

"Lua Programming Gems" by de Figueiredo, Celes and Ierusalimschy, also Lua.org.

 

While developing I often bind the lua scripts to be executed by key presses (often the numeric keys). And I use tail to keep an eye on the log file.

 

Ah, do you mean debugging, as opposed to efficient end results?

 

Two techniques which you can of course mix. One is to program lots of logging into the script in the first place, logging important steps and values, but made conditional on a boolean value being true. Just define, eg "Debug=true" at the beginning, and hen all is working change it to "false".

 

The other is just to use the debug/trace facility built in (see FSUIPC Logging tab). This logs every change to every variable and the line in which it occurs, but it needs enabling BEFORE the subject Lua plug-in starts.

 

If you do actually mean efficiency in execution, then always consider using the event library, with your plug-in preloaded (via an [Auto] macro, or by loading it in the ipcReady.lua plugin) unless the action is infrequently needed and always in response to a keypress or button action.

 

Pete

Link to comment
Share on other sites

Thank you for your quick response. 

 

I guess was a bit unclear. Sorry.

 

When talking about "develop efficiently" I mean the actual developing/programming process. It's the fact that you need to bind the lua script you're working on to a keypress (or similar) to be able to execute it at will while you're developing/testing it. It is this part that I feel is a bit "clumsy".

 

I suppose it is because the ipc library needs to run "inside" FSX there are limited ways to execute the scripts. I mean you can't use the windows command promt - right?

 

It would be great if you could access the scripts by a console/promt/terminal and work with the scripts that way by using commands.

Link to comment
Share on other sites

I'm new to Lua, but it can be compiled or interpreted I understand. Meaning, with the right utility, you could develop you script outside of FSX (spoofing relevant I/O of course) without having to fire up the sim every time. I do this with my Arduino code, communicating with serial port windows and making sure the code is working as I want before I hook it up with Lua/FS. But if you are looking for the equivalent of an "in-system debugger", I am too newbie myself to know. -Dave

Link to comment
Share on other sites

When talking about "develop efficiently" I mean the actual developing/programming process. It's the fact that you need to bind the lua script you're working on to a keypress (or similar) to be able to execute it at will while you're developing/testing it. It is this part that I feel is a bit "clumsy"

 

Well, it must either be a keypress or button, or, if you want to write a program, you could start a Lua by writing the command to an offset. Seems a bit, er, complicated, compared to pressing a key?

 

It would be great if you could access the scripts by a console/promt/terminal and work with the scripts that way by using commands.
 
You would have to write a program to send the request to FSUIPC. Do you really think that would be "tidier" or "more efficient"? I certainly don't.
 
If you just want to develop and test programs which don't use any of the libraries provided by FSUIPC to interact with FS, then there are such development environments available. Have a look on the Lua website, I'm sure you'll find links to them there. I suppose you could put dummy calls in for any FSUIPC Lua library calls you wanted, and try to test the logic separately. But you'd need to be developing really seriously complicated programs to really justify that. Most plug-ins are pretty simple and rarely need any complicated testing at all.
 
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.