A Nasal script for FlightGear landing drills in the 777, and some bug workarounds

This was the first page on the topic. I now have a newer version.

The purpose of this script is to appear in the air very close to the near end of a runway and do landing drills over and over. The script automatically "presses" the 15 or so buttons you need to land. It also works around some bugs I've encountered. For one of the bugs, I changed a FlightGear file as opposed to using my own script.

At the moment, there are almost certainly unpleasant side effects to this script if you're not landing. You'll have to rename the script to anything other than *.nas (such as landing_drill.notnas) and restart FG to remove it. I may work on those side-effects soon, or feel free to run with it, of course.

I've only tried this on the Boeing 777 200-ER in, although I think it works in

The script sets these initial conditions:

The Script Itself

In Windows 7, this goes in your equivalent of C:\Users\<user>\AppData\Roaming\flightgear.org\Nasal\anything.nas . It has to be a .nas, such as landing_drill.nas. (See "User specific Nasal scripts" at the bottom of this linked page)

The Context I'm Using It In

My specific settings are as follows, but you can do the same thing at any runway. I'm setting my location in the FlightGear Wizard "Advanced" settings just before you hit the final "run." From the screen, you have to enter Lat / Lon rather than distance from runway:

Latitude 33.6347

This is very close to KATL runway 9L. As I recall, this is exactly 2nm from the near end of the runway. DME shows 3.7nm (from the far end). This is 720 - 770 feet AGL. This is a precise point where the fall upon start / restart takes you through the glide slope such that you get an immediate glideslope indication--that is the "more below" regarding glideslope flight director indication: you have to get distance to runway versus altitude just right to get immediate gs indication. Also, your NAV1 must be set to the right runway.

Note that you'll almost certainly crash the first time you run FG (as opposed to reinit / shift-esc) because you don't have enough control before the plane drops. Once you hit shift-esc (reinit), though, you should be good to go over and over. This script is doing exactly what I want it to, except for one lingering bug which I think is in the C++ (more below).


Script Effects on Plane Features

Spoilers / Speedbrake

Update: The auto-speedbrake bug was not in the C++. Here is my fix.

Original verbiage: This script overrides / works around what seems to be a bug in the C++ (as opposed to Nasal) such that (auto) spoilers don't work and / or I've seen the lever go to "Up" (active) and then immediately go "Down" (inactive). The script forces the speedbrakes to stay active once engaged until you get below 85nmph. If you engage them accidentally before that, you're in trouble. (I may write more code to account for this later.) The auto spoilers either almost never or never work in my experience. Even with this script setting them to auto, I almost always have to engage them manually, although now they at least work manually.

Autospoilers (continued) - The Last Feature / Bug (original verbiage)

My one big dissatisfaction with my landing drill script is that auto speedbrake / auto spoilers / "speedbrake armed" generally does not work [fixed, above]. Other than that, I am tickled with this. It's some of the most satisfying coding I've done in a long time--hours of amusement. I may have to go after that auto spoiler bug [done]. Again, I don't think there is anything I can do in my own Nasal script [no need], and I don't think it's in the pre-existing Nasal [yes, it is, fixed above]. In other words, I think it's in the C++ [wrong], but hopefully I'm wrong [I was].

Auto Throttle

This script also overrides a bug where the auto throttle "magically" comes on occasionally once I've disengaged it and am almost on the runway (like 50 - 100 feet above). With the script, disengaging the AT (Ctrl-S) turns the left/right A/T ARM buttons off such that "magic" re-engagement won't happen.

Glideslope Tunnel

It seems to take the 2nd reinit (3rd landing) before this turns on.

Programming Discussion

To quote this Mythbusters, here is "why I did what I did, and why I didn't do what I didn't do."

First of all, the April 4, 11:14pm version is a bit messy from a coding standpoint, but I'm so happy with the results that I want to put this out before I clean it up (if I clean it up). Hopefully you'll have as much fun with this as I do.

To the details: on three related points, you may wonder why 1) I have "doSettings" and "initOnce" functions, and 2) why I don't use some of the singals, and 3) why I have to use the "frame" signal (several times before deactivating the listener). (For signals, see the bottom of this linked page).

I found that the "initOnce" settings only have to be done upon each reinit. I found that the "nasal-dir-initialized" and "fdm-initialized" signals were totally useless. It seems that "something" (probably C++ and not Nasal) overrides some of my signals for several frames. The "print" functions show you that the AT target changes for the first few frames, and I included a few more frames for good measure. Doing the first 30 frames, for example, still didn't work sometimes.

I found that when you did a replay, the speedbrake listener would get called over and over.

More Discussion / Changes to Come (???)

I think I'll stop for now and get this out. As I said, I'm having so much fun with this that I want to spread the joy. :) Hopefully I'll clean up the script and have more to say later.

Spread the Word!

If you find it useful, please spread the script and my bug fixes (on the other page) and this documentation. I'd like attribution, but I don't insist on it. Off hand, I couldn't find a list of FG contributors, and no one should have to start such a potentially tedious list just for me. FG is open source, so use my stuff in that spirit.

On a similar note, one day I'll probably post some of this to FG forums, but don't assume I will. Spread it yourself if you think it's useful.


First, I love FG, so thanks to everyone who had a part! I also wanted to specifically mention "How to Autoland" (at the bottom). I found that very helpful.

A sort-of funny note

On the same day that I started playing with a language called "Nasal" (Monday April 1) and the day after, it seems allergy season began in Atlanta. Two people I know got a bit sick. Better to learn Nasal this week than BE nasal.

Page History

2013/08/27 10:09pm EDT - updated the auto-speedbrake verbiage

04/05 2:30am - that would be shift-esc, not control-esc

Created 2013/04/04 11:54pm EDT or a bit later.

Valid XHTML 1.0 Strict