Activate
I actually got that working by adding + and - buttons that would increase or decrease the airspeed target by increments, and changing the SET button to an engage ENG button. So I can set the airspeed target, hit engage, and the autopilot will engage. Doing it with MFD buttons while flying is probably preferred to having to go to the keyboard to fill out a dialog box. I see that you used oapi.receive_input() instead of proc.wait_input(). I might try implementing that and see if it works and if I like it. The +/- keypresses seems to work well while flying.
Good to hear you got it working. I also don't really like popup windows, as I feel that they break the immersion, especially on ships with a nice VC. The method you chose is probably better. Perhaps add a "factor" or "adj" button to change the scale of the increased/decreased value. (ie: x1, x10 x100 )
One side note though, you are getting the airspeed in the local (vessel) reference frame and you are using the z component of that vector to calculate the airspeed. Are you sure you want it like that? If your nose is pointing down and you are doing 200 m/s vertical, it will register as 200 m/s in the z direction of the vessel's local frame, even though you'll have no horizontal speed. Perhaps the local horizon frame would be a better pick? Or even get_groundspeed() (that is a scalar, not a vector).
Unless that's how you want it to behave, so that it doesn't turn on the engines when the ship is not fighting gravity (which makes sense I suppose).
One side question - is there any way to check the Lua script before attempting to load it in Orbiter? Right now I am finding bugs in my code when I go to try to load the MFD and it fails and crashes which tells me something is wrong but doesn't really tell me what is wrong.
Activate LuaConsole in the modules tab.
Hit F4 or click on the functions button in the top/center infobar and select Lua Console Window.
In the window type: run_global("Config/MFD/AirspeedHold.cfg")
Since it is an ScriptMFD .cfg file, it will not actually run a Lua script in Orbiter, but it should return errors (and the corresponding lines) if they occur. (unclosed parentheses, unexpected returned values... not closed if statements... things like that).
For example:
Config/MFD/AirspeedHold.cfg 21: '}' expected to (to close '{' at line 18) near 'function'
Any changes you make to the cfg file, won't turn up directly in Orbiter, you'll need to close the simulation and run the scenario again.
Direct Lua scripts on the other hand, run "live", so if you get an error, you can see where it is, make the change and run it again via the run("scriptname") command. (needs to be a .lua file).
The path for the run_global command is your Orbiter root and you need to enter the file extension, while the path for the run command is the Orbiter root\Script folder and you don't enter the extension (it is assumed to be a lua file).