It's not really complicated at all, if you know some JavaScript it will be really easy to understand how the whole thing works.
All of this is basically written in about 20 lines of Nasal code, so it's compact too.
You will need to save the file as "copilot.nas" in $FG_ROOT/Nasal
# copilot.nas (to be placed in $FG_ROOT/Nasal)
##
# implements a very simple prototype of a timer based virtual 'copilot' script in Nasal issuing "FREDA" reminders to the console, screen and to the festival TTS
# see: {{forum url|t=9556}}
#
# for details on FREDA please see:
# http://www.worldlingo.com/ma/enwiki/en/Freda
# http://www.squidoo.com/learning-to-fly-freda-pats-the-cat
#
# TODO: these settings should probably become property based, so that they can be easily configured using a GUI dialog
# configuration settings (0: disabled, 1: enabled for boolean settings)
var config = {enable_freda:1, print_to_console:1, print_to_screen:1, use_festival:0, reminder_delay_mins:1, gui_message_delay_secs:5 };
# vector with FREDA messages
var FREDA = [
"FREDA (fuel):ensure fuel is sufficient and being consumed at the expected rate. 'Lean out' the carburettor to the most economical setting. Set the fuel selector switch to take fuel from one or other of the wing tanks, or both, depending on fuel remaining and aircraft balance limits",
"FREDA (radio):ensure the radio is tuned to the correct frequency for the nearest airfield. Listen for announcements. Communicate with airfield when entering or leaving restricted airspace",
"FREDA (engine):check oil temperature and pressure, and other engine indicators.",
"FREDA (DI):check directional indicators (compass, gyroscope, artificial horizon, etc.) to ensure correct heading.",
"FREDA (altimeter):check altimeter shows correct altitude. Gain or lose height if necessary. Adjust altimeter to the correct atmospheric pressure setting for the local area",
];
var minutes_to_seconds=60;
var delay_secs = config.reminder_delay_mins*minutes_to_seconds;
var remind = func(msg) {
if (config.print_to_console) print(msg);
if (config.print_to_screen) screen.log.write(msg); #gui.popupTip(msg, config.gui_message_delay_secs);
if (config.use_festival) setprop("/sim/sound/speech", msg);
};
var print_freda_reminders = func {
foreach (var msg; FREDA )
remind(msg);
settimer(print_freda_reminders, delay_secs);
};
var init_copilot = func {
if (!config.enable_freda) return;
if (config.use_festival and getprop("/sim/sound/voices/enabled")!=1) print("Warning: /sim/sound/voices/enabled is 0");
settimer(print_freda_reminders, delay_secs);
print('Copilot script initialized and running, next reminder due in ',config.reminder_delay_mins, ' minutes' );
};
# register the callback for running the init function
_setlistener("/sim/signals/nasal-dir-initialized", init_copilot);