Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Orbiter Lua Scripting
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter Lua Scripting Find support, share snippets and general discussion around using the Lua engine in Orbiter.

Reply
 
Thread Tools
Old 10-26-2017, 03:00 PM   #1
Ripley
Tutorial translator
 
Ripley's Avatar
Question What can we do with Lua

First, sorry for the extreme noobiness of my post/request.

I think that I, for one, could really enjoy a very general post in this new Lua subforum where someone presents and briefly explains to those who don't know what Lua is, what can be done with it in Orbiter.

I know it's a scripting language ok, I know there's a "Script Interface" chapter in the official Orbiter.pdf documentation, but I also feel it's a rather unexploited/underrated Orbiter "feature".
The only Lua use I saw around (other than what comes with Orbiter default install) is those scripts written mainly by dgatsoulis in the "Tutorials & Challenges" section.

Thanks.

Last edited by Ripley; 11-11-2017 at 09:46 AM.
Ripley is offline   Reply With Quote
Old 10-26-2017, 03:54 PM   #2
4throck
Enthusiast !
 
4throck's Avatar
Default

Open Orbiter and press the help button All the script functions are explained there.

For a short answer, it's a text file that gets interpreted, in real time, by orbiter, and can access it's internal functions.
So you can do almost all that can be done in Orbiter with it, with no need for C++ code.

You can do MFDs or configure vessels with Lua.
For example, you can animate cockpit dials in real-time, automate systems, etc.

I'm working on a Gemini B MFD that handles the reentry sequence, expanding the normal SC3 vessel abilities.
Specifically, I use Lua to create the retrorockets when needed, fire them at the right intervals, jetisson modules, open parachute, etc, etc.
Really powerful.

I guess it can be used to have dummy vessels circling around bases, or some traffic around ISS, for example.

It's NOT well suited for things that require key presses or saving states.

Last edited by 4throck; 10-26-2017 at 04:00 PM.
4throck is offline   Reply With Quote
Thanked by:
Old 10-26-2017, 04:47 PM   #3
N_Molson
Addon Developer
 
N_Molson's Avatar

Post

The main pro is that you can run lua - I don't think it has caps in the name right ? - from inside an Orbiter simulation session, it's a bit the Inception of programming :p The obvious application is of course guidance programs for rockets or autopilots that you can run through a Console MFD, which also is quite immersive. You can load a pre-written script with a "run" command through that console, or even enter it "live" (say, if you only need one simple thing). You have an example with the ascent guidance program for the default Space Shuttle Atlantis. It can even display the instructions and their state, which looks cool (and can be handy).

The other way requires to write and compile a .dll (Dynamic Link Library) plugin, which is a Microsoft format, correct me if I'm wrong. It really isn't that hard, but for beginners the compiler (MS Visual Studio) setup itself can be a bit daunting. You can do nearly everything, but a .dll is quite a closed box and you'll have to recompile it for modifications, which can't be done from Orbiter inside. There is a way to run Orbiter through the compiler - aka the debugger - which helps you a bit from going back and forth Visual Studio and Orbiter. But still, having to recompile everything to track bugs is... not very handy. There are however ways to go around that "closed" aspect of the .dll like storing variables into a third-party file (like a .cfg or .scn, which is a mere text file with a different extension). Or you can even program an editor with integrated GUI that allows more flexibility (the Scenario Editor you have in Orbiter is actually a .dll plugin). Also there is the graphical stuff which can - I think - only be handled by a .dll (like panels, virtual cockpits, custom interfaces, even graphic clients...)

Both can be useful, really. Still a lot of devs use .dll because they are professionals that already have an extensive knowledge of C++. Maybe people also think "oh man compiling a .dll looks so pro I'm going to do that !". And - maybe this is the most important point - having a "closed box" can be quite convenient if you don't want people to mess with your own stuff (also solving 'rights' issues in commercial uses - this isn't the case in Orbiter as you can't sell addons, Martins was very clear from the start, which allows the whole thing to stay 100% free -). You can provide the source files with your plugin so that other people are able to recompile it but that is totally up to you. Again it can be professional habit not to share your knowledge for free (though the vast majority of addons devs do share their source files). Or it can even be a lack of confidence, I'd personally would fit in that category as I am a pure hobbyist and can think "oh professionals are going to have a good laugh if they see my very messy way of doing things". You don't have that with lua. AFAIK you can't "close" a lua script in the Orbiter context. I don't know the legal details but lua is "open source" in mind.

Also until very recently lua functions were a bit under-documented and its why it is very interesting to see more interest on that side. It can really allow a lot of people to adapt existing things (typically autopilots) to their needs by replacing variables values. You can do that with the Atlantis sample in a few seconds. Definitively there is a lot of room for tutorials and things like that. Orbiter has become a huge project and we can't expect Martins to take care of everything, even if he wanted that would probably be impossible. So

Last edited by N_Molson; 10-26-2017 at 05:00 PM.
N_Molson is offline   Reply With Quote
Thanked by:
Old 10-26-2017, 04:53 PM   #4
Donamy
Beta Tester


Default

Yes, please more examples.
Donamy is offline   Reply With Quote
Old 11-05-2017, 09:29 PM   #5
BEEP
Addon Developer
Default

I'd think that developing community sim resources in an open code format is mandatory as the amounting experience regarding the avoidable obsolescence of cherished and sometimes essential legacy assets has shown. Orbiter is a good example in this particular but it is not the only one. My coding is very questionable and sometimes deliberately so due to development path options and decisions. I'm not ashamed in any way because a critic would be out of place. Community addon development does not need to follow the practices intended for industrial market products. In fact I gave up calling version "betas" as I've found out that these are forever developments. This is a hobby and its done for fun allowing for more creativity and risk taking than in commercial, professional environments. Using the same criteria ( even when pure logic applies) to analyse this kind of software is not only unwise but a waste of time.

Last edited by BEEP; 11-05-2017 at 10:00 PM.
BEEP is offline   Reply With Quote
Thanked by:
Old 11-06-2017, 02:21 AM   #6
ADSWNJ
Scientist
 
ADSWNJ's Avatar
Default

I think open vs closed is the wrong argument for lua vs C++. There's tons of C++ in this community that is fully open (including all of my addins, for example). Lua is a fine environment for scripting and prototyping, but is nowhere near as sophisticated as C++ if you want to get into high performance or deeper levels of integration. That said ... if your first steps into giving back to this community are via lua, then I applaud you, and if I can help anyone interested in taking the next step into C++, then PM me.
ADSWNJ is offline   Reply With Quote
Thanked by:
Old 11-08-2017, 02:26 PM   #7
4throck
Enthusiast !
 
4throck's Avatar
Default

It's good to have a solution (Lua) that forces the community to break down the problems into manageable parts.

Most of us don't have much time. So being able to develop something, let's say 30 minutes each day, and get results is important.
Specially for people that don't use C++ or visual studio everyday


Having the source code solves nothing. We do have it. But updating is too complex and time consuming, because Orbiter itself has become complicated.

So its important that more and more people start creating, and have an accessible tool to do so!
4throck is offline   Reply With Quote
Thanked by:
Old 11-10-2017, 08:28 PM   #8
kuddel
Donator
Default

Let's not make this into a "mine's better than yours" war
I would definitely recommend C++, as I am more used to it.
But I can also fully understand the Lua lobbyists.

Everybody can freely choose what to do
(some things however might still force you into one or the other, but that's fact-driven not opinion-driven)
kuddel is offline   Reply With Quote
Thanked by:
Old 11-11-2017, 02:02 AM   #9
ADSWNJ
Scientist
 
ADSWNJ's Avatar
Default

Kuddel is right ... choose the tool you are happy with, and create what you want. It's amazing to think that behind the video output of this magnificent simulation is an ocean of data and control points for you you do whatever you want. From the simplest of outputs of data (to the exact precision you want), to the most complex of control systems ... it's all within reach from LUA or C++ as you prefer.

There's some learning curve for C++, but you don't need to be a daily programmer and deep guru to learn it, and you can still do it 30 mins at a time, especially with a bit of help to get started. My philosophy is to "pay it forward"... I learnt so much from others in this forum, and I want to repay it by passing on some knowledge to others. Who wants to take me up on this?
ADSWNJ is offline   Reply With Quote
Thanked by:
Old 11-11-2017, 07:27 AM   #10
Face
Beta Tester
 
Face's Avatar

Default

Quote:
Originally Posted by N_Molson View Post
 The main pro is that you can run lua - I don't think it has caps in the name right ? - from inside an Orbiter simulation session
Quote:
Originally Posted by N_Molson View Post
 You can do nearly everything, but a .dll is quite a closed box and you'll have to recompile it for modifications, which can't be done from Orbiter inside.
I think these two statements nailed it for me. Lua is explorable from inside Orbiter itself, while DLLs are generally not. This way, it offers a possibility for non-coders to explore the features of the Orbiter API on the go.

Keep up the good work, kuddel!
Face is offline   Reply With Quote
Thanked by:
Old 11-11-2017, 09:18 AM   #11
jedidia
shoemaker without legs
 
jedidia's Avatar
Default

Quote:
You can do nearly everything, but a .dll is quite a closed box and you'll have to recompile it for modifications, which can't be done from Orbiter inside.
Weirdly enough, that's one of the main cons for me. I like my compile-time type checking

Quote:
It's good to have a solution (Lua) that forces the community to break down the problems into manageable parts.
That's really just a matter of proper encapsulation, though. But of course encapsulation is a major problem for programming beginners, and visual studio project setups tend to drive you nuts when you're not sure what you're actually doing.

That, C++'s godawful include handling which can be an annoying time sink even for professionals in larger projects, and the equally godawful syntax of the STL are what makes the lua option a good choice to get some results fast, especially for beginners.
Until the project becomes too complex and the lack of type checking and a solid debugger start to drive you nuts. As far as I remember, lua didn't really have any type checking at all, not even at runtime. It would just throw weird exceptions if types didn't match, or just acted weirdly when you were unlucky enough for the table you passed actually having the field you were querying, but it meaning something entirely different in this table than in another.

Last edited by jedidia; 11-11-2017 at 09:30 AM.
jedidia is offline   Reply With Quote
Thanked by:
Old 11-12-2017, 05:59 PM   #12
4throck
Enthusiast !
 
4throck's Avatar
Default

Quote:
Originally Posted by jedidia View Post
 Until the project becomes too complex and the lack of type checking and a solid debugger start to drive you nuts.
1000% agree. That forces you to structure your work and do some debugging yourself. And that's a great learning process, although time consuming.
4throck is offline   Reply With Quote
Old 11-12-2017, 06:31 PM   #13
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by 4throck View Post
 1000% agree. That forces you to structure your work and do some debugging yourself. And that's a great learning process, although time consuming.
Its first of all "Learning by pain". You will NEVER learn this properly by a textbook alone. But a textbook can give you better ideas how to ease your pain of course.

Also, to give a few cents more here: Having the source code available is not the same as making it easy to understand what is going on there. Good examples should have a few comments more than a good developer needs for remembering what he did last summer. Ideally even a short HTML manual to explain things you can't explain by source code alone.
Urwumpe is online now   Reply With Quote
Thanked by:
Reply

  Orbiter-Forum > Orbiter Addons > Orbiter Lua Scripting


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 02:59 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.