ELTmessage.nas 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #Basic ELT (Emergency Locator Transmitter)
  2. #Authors: Pavel Cueto, with A LOT of collaboration from Thorsten and AndersG
  3. #Be sure to link this Nasal in -set file, typing:
  4. #<nasal>
  5. # <ELT>
  6. # <file>YOUR/INSTRUMENT/FOLDER/ROUTE/HERE/ELTmessage.nas</file>
  7. # </ELT>
  8. #</nasal>
  9. print('Emergency Locator Transmitter (ELT) loaded');
  10. #Aircraft ID definition
  11. var aircraft = getprop("/sim/description");
  12. var callsign = getprop("/sim/multiplay/callsign");
  13. var aircraft_id = aircraft ~ ", " ~ callsign;
  14. var ground = getprop("/position/altitude-agl-ft");
  15. #Print an emergency auto-message when aircraft crashes
  16. setlistener("/sim/crashed", func(msg) {
  17. if ((getprop("/sim/crashed")) and (ground < 1)) {
  18. var lat = getprop("/position/latitude-string");
  19. var lon = getprop("/position/longitude-string");
  20. var help_string = "ELT AutoMessage: " ~ aircraft_id ~ ", CRASHED AT " ~lat~" LAT "~lon~" LON, REQUESTING SAR SERVICE";
  21. setprop("/sim/multiplay/chat", help_string);
  22. # settimer(msg, 1);
  23. }
  24. });
  25. #Print an emergency message when pilot turns on the "armed" button
  26. setlistener("/ELT/armed", func(alrm) {
  27. if (getprop("/ELT/armed")) {
  28. var lat = getprop("/position/latitude-string");
  29. var lon = getprop("/position/longitude-string");
  30. var help_string = "ELT Message: " ~ aircraft_id ~ ", DECLARING EMERGENCY AT " ~lat~" LAT, "~lon~" LON";
  31. setprop("/sim/multiplay/chat", help_string);
  32. }
  33. });
  34. #Print a message when pilot turns on the "test" button
  35. setlistener("/ELT/test", func(alrm) {
  36. if (getprop("/ELT/test")) {
  37. var lat = getprop("/position/latitude-string");
  38. var lon = getprop("/position/longitude-string");
  39. var help_string = "ELT Message: " ~ aircraft_id ~ ", EMERGENCY TEST AT " ~lat~" LAT, "~lon~" LON";
  40. screen.log.write(help_string);
  41. }
  42. });