Gnat_T1.nas 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. var gear_indicators_loop = func {
  2. var gear0 = getprop("/gear/gear/position-norm");
  3. var gear1 = getprop("/gear/gear[1]/position-norm");
  4. var gear2 = getprop("/gear/gear[2]/position-norm");
  5. var gearTotal = (gear0 + gear1 + gear2) ;
  6. if (gear0 == 1){
  7. setprop("/Gnat_T1/gear0_DN", 1);
  8. setprop("/Gnat_T1/gear0_UP", 0);
  9. }
  10. if (gear0 == 0){
  11. setprop("/Gnat_T1/gear0_DN", 0);
  12. setprop("/Gnat_T1/gear0_UP", 1);
  13. }
  14. if (gear0 > 0 and gear0 < 1){ # transit
  15. setprop("/Gnat_T1/gear0_DN", 0);
  16. setprop("/Gnat_T1/gear0_UP", 0);
  17. }
  18. if (gear1 == 1){
  19. setprop("/Gnat_T1/gear1_DN", 1);
  20. setprop("/Gnat_T1/gear1_UP", 0);
  21. }
  22. if (gear1 == 0){
  23. setprop("/Gnat_T1/gear1_DN", 0);
  24. setprop("/Gnat_T1/gear1_UP", 1);
  25. }
  26. if (gear1 > 0 and gear1 < 1){ # transit
  27. setprop("/Gnat_T1/gear1_DN", 0);
  28. setprop("/Gnat_T1/gear1_UP", 0);
  29. }
  30. if (gear2 == 1){
  31. setprop("/Gnat_T1/gear2_DN", 1);
  32. setprop("/Gnat_T1/gear2_UP", 0);
  33. }
  34. if (gear2 == 0){
  35. setprop("/Gnat_T1/gear2_DN", 0);
  36. setprop("/Gnat_T1/gear2_UP", 1);
  37. }
  38. if (gear2 > 0 and gear2 < 1){ # transit
  39. setprop("/Gnat_T1/gear2_DN", 0);
  40. setprop("/Gnat_T1/gear2_UP", 0);
  41. }
  42. if (gearTotal > 0 and gearTotal < 3){ # transit
  43. setprop("/Gnat_T1/gearTransit", 1);
  44. }
  45. else {
  46. setprop("/Gnat_T1/gearTransit", 0);
  47. }# all done
  48. settimer(gear_indicators_loop, 0.2);
  49. }
  50. setlistener("/sim/signals/fdm-initialized", func { # ====================== initialization
  51. setprop("/Gnat_T1/gear0_DN", 1);
  52. setprop("/Gnat_T1/gear1_DN", 1);
  53. setprop("/Gnat_T1/gear2_DN", 1);
  54. setprop("/Gnat_T1/gearTransit", 0);
  55. setprop("/Gnat_T1/gear0_UP", 0);
  56. setprop("/Gnat_T1/gear1_UP", 0);
  57. setprop("/Gnat_T1/gear2_UP", 0);
  58. setprop("/gear/gear/position-norm", 1);
  59. setprop("/gear/gear[1]/position-norm", 1);
  60. setprop("/gear/gear[2]/position-norm", 1);
  61. gear_indicators_loop();
  62. print ("Gnat_T1 loaded");
  63. })