General Question LUA Scripting Issues

flyer

Member
Joined
Jan 20, 2010
Messages
56
Reaction score
0
Points
6
Hi there guys,

I'm looking into attempting to create a LUA script for orbiter and have been trying to get to grips with the basics of LUA by looking at the example scripts included with O2010.

Unfortunately I am getting errors when I try to run the "script\demo\demos.lua" file.

I have tried it with a completely clean install of O2010 (not even orbitersound installed!) and the same problem occurs as when I had all of my usual addons installed.

I can run the demos.lua file from within orbiter and this is where the problems start...

If I run the demos file from the LUA console window then I can type help() and run each of the mentioned functions except for the demo_focus() which causes an immediate crash to desktop. This also happens within the Terminal MFD.

The demo_mon() function runs ok in the console window, but the following occurs when I try to run it from the Terminal MFD:


Demo for monitoring a parameter state.

GL-01 altitude:

Execution error.


For reference I am trying it with the default Delta-Glider\Cape Canaveral scenario.

Does anyone have any clue as to what is happening?

I don't think the orbiter.log shows anything of use but if people think it would help I can post it.

I have been looking through the documentation as well, but not being able to get the supplied basic functions to work is making it tough for me to learn.

Any help is appreciated!

Cheers,


Flyer


...also, is there any way to control the airbrakes via lua? I see in the documentation that it is possible to assign a function to things like the gear retraction/extension, but this seems to involve modifying the source code of the vessel. Is there a more generic way of doing this? I have even tried the send_bufferedkey method to activate the airbrakes that way. Unfortunately, the DG requires simultaneous pressing of CTRL and B which I don't know how to do given my limited experience with LUA (I only started looking at it yesterday!)

Any help is appreciated, thanks again

---------- Post added 18-06-10 at 21:38 ---------- Previous post was 17-06-10 at 22:51 ----------

Just to add some more info, I've created a lua script which in the end I hope will open and close the airbrake to maintain a given speed on final approach.

So far I have managed to get a visual text message to indicate what the state of the airbrakes would be for the current situation. The rules I have programmed into it are: when in the air the airbrakes will open above 205m/s and close below 195m/s : when on the ground with thrust set below 70% and speed above 30m/s the airbrakes will be open.

It's probably quite a clunky way of achieving this but in principle it seems to work.

There may be an addon that already exists which will achieve this, but I haven't seen it yet (maybe within one of the shuttle specific addons?). But anyway, this has been an interesting experience for me and I'm pleased with what I have so far.

If anyone knows of a way to control the airbrakes via LUA without needing to modify the source code of a vessel (which is what I understand would need to be done) then I'd appreciate any help.

Thanks again!


Flyer


Another update...I've got this working on the DGIV since the airbrakes on that are controlled by the B key only (unfortunately it only seems to be 0 or 100% airbrake extension due to a limitation of orbiter). But now I'm having trouble with the oapi.set_pause(false) command. It just doesn't seem to work which is strange because the same command with true entered works without trouble?! So I can pause the simulation but I can't unpause it!

Again, if anyone has any ideas or wants more info then let me know!
 
Last edited:
Just messing around some more and have produced an auto gear extension function as well - not particularly tricky and it does have some limitations but it does the trick!

Looking at calculating some speeds for takeoff next...not very useful but it's good to get into the language a bit more.

Anyone have any ideas about my previously mentioned problems?
 
Last edited:
I cant help with your problem, but I will say, being able to do multiple keystroke would be good, and I feel should already be doable.
 
Back
Top