doors.nas 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. # =====
  2. # Doors
  3. # =====
  4. doors = {};
  5. doors.new = func {
  6. obj = { parents : [doors],
  7. frontl : aircraft.door.new("/sim/model/ec130/doors/frontl", 3.0),
  8. frontr : aircraft.door.new("/sim/model/ec130/doors/frontr", 3.0),
  9. passengerl : aircraft.door.new("/sim/model/ec130/doors/passengerl", 3.0),
  10. passengerr : aircraft.door.new("/sim/model/ec130/doors/passengerr", 3.0),
  11. luggagel : aircraft.door.new("/sim/model/ec130/doors/luggagel", 3.0),
  12. luggager : aircraft.door.new("/sim/model/ec130/doors/luggager", 3.0),
  13. doorb : aircraft.door.new("/sim/model/ec130/doors/doorb", 2.0),
  14. pilotw : aircraft.door.new("/sim/model/ec130/doors/pilotw", 1.0),
  15. basketl : aircraft.door.new("/sim/model/ec130/doors/basketl", 2.0),
  16. basketr : aircraft.door.new("/sim/model/ec130/doors/basketr", 2.0),
  17. hook : aircraft.door.new("/sim/model/ec130/doors/hook", 2.0),
  18. mgpu : aircraft.door.new("/sim/model/ec130/mgpu", 7.0)
  19. };
  20. return obj;
  21. };
  22. doors.frontlexport = func {
  23. me.frontl.toggle();
  24. }
  25. doors.frontrexport = func {
  26. if ( getprop("/sim/model/variant") == "1" ) {
  27. # EC130 B4 has door dependencies on right side
  28. if ( !getprop("/sim/model/ec130/doors/passengerr/position-norm") ) {
  29. me.frontr.toggle();
  30. } else {
  31. screen.log.write("Passenger Door must be closed !!!");
  32. }
  33. } else {
  34. # H130 has no door dependencies on right side
  35. me.frontr.toggle();
  36. }
  37. }
  38. doors.passengerlexport = func {
  39. if ( !getprop("/sim/model/ec130/doors/luggagel/position-norm") ) {
  40. me.passengerl.toggle();
  41. } else {
  42. screen.log.write("Luggage Door blocks Passenger Door !!!");
  43. }
  44. }
  45. doors.passengerrexport = func {
  46. if ( getprop("/sim/model/variant") == "1" ) {
  47. # EC130 B4 has door dependencies on right side
  48. if ( !getprop("/sim/model/ec130/basket_right") and getprop("/sim/model/ec130/doors/frontr/position-norm") ) {
  49. me.passengerr.toggle();
  50. } else {
  51. if ( !getprop("/sim/model/ec130/doors/frontr/position-norm") ) {
  52. screen.log.write("Front Door must be open !!!");
  53. }
  54. if ( getprop("/sim/model/ec130/basket_right") ) {
  55. screen.log.write("Basket blocks Passenger Door !!!");
  56. }
  57. }
  58. } else {
  59. # H130 has same slide door dependencies as left side
  60. if ( !getprop("/sim/model/ec130/doors/luggager/position-norm") ) {
  61. me.passengerr.toggle();
  62. } else {
  63. screen.log.write("Luggage Door blocks Passenger Door !!!");
  64. }
  65. }
  66. }
  67. doors.luggagelexport = func {
  68. if ( !getprop("gear/gear[0]/wow") and !getprop("gear/gear[1]/wow") and !getprop("gear/gear[2]/wow") and !getprop("gear/gear[3]/wow") ) {
  69. screen.log.write("Only possible on ground !!!");
  70. return;
  71. }
  72. if ( !getprop("/sim/model/ec130/doors/passengerl/position-norm") ) {
  73. if ( !getprop("/sim/model/ec130/doors/basketl/position-norm") ) {
  74. me.luggagel.toggle();
  75. } else {
  76. screen.log.write("Left basket must be closed !");
  77. }
  78. } else {
  79. screen.log.write("Passenger Door blocks Luggage Door !!!");
  80. }
  81. }
  82. doors.luggagerexport = func {
  83. if ( !getprop("gear/gear[0]/wow") and !getprop("gear/gear[1]/wow") and !getprop("gear/gear[2]/wow") and !getprop("gear/gear[3]/wow") ) {
  84. screen.log.write("Only possible on ground !!!");
  85. return;
  86. }
  87. if ( getprop("/sim/model/variant") == "1" ) {
  88. if ( !getprop("/sim/model/ec130/doors/basketr/position-norm") ) {
  89. me.luggager.toggle();
  90. } else {
  91. screen.log.write("Right basket must be closed !!!");
  92. }
  93. } else {
  94. # H130 same luggage door dependencies as left side
  95. if ( !getprop("/sim/model/ec130/doors/passengerr/position-norm") ) {
  96. if ( !getprop("/sim/model/ec130/doors/basketr/position-norm") ) {
  97. me.luggager.toggle();
  98. } else {
  99. screen.log.write("Right basket must be closed !");
  100. }
  101. } else {
  102. screen.log.write("Passenger Door blocks Luggage Door !!!");
  103. }
  104. }
  105. }
  106. doors.doorbexport = func {
  107. if ( !getprop("gear/gear[0]/wow") and !getprop("gear/gear[1]/wow") and !getprop("gear/gear[2]/wow") and !getprop("gear/gear[3]/wow") ) {
  108. screen.log.write("Only possible on ground !!!");
  109. return;
  110. }
  111. me.doorb.toggle();
  112. }
  113. doors.pilotwexport = func {
  114. if ( !getprop("/sim/model/ec130/doors/frontl/position-norm") ) {
  115. me.pilotw.toggle();
  116. } else {
  117. screen.log.write("Pilot window operable with closed door only !!!");
  118. }
  119. }
  120. doors.basketlexport = func {
  121. if ( !getprop("gear/gear[0]/wow") and !getprop("gear/gear[1]/wow") and !getprop("gear/gear[2]/wow") and !getprop("gear/gear[3]/wow") ) {
  122. screen.log.write("Only possible on ground !!!");
  123. return;
  124. }
  125. if ( getprop("/sim/model/ec130/basket_left") ) {
  126. me.basketl.toggle();
  127. }
  128. }
  129. doors.basketrexport = func {
  130. if ( !getprop("gear/gear[0]/wow") and !getprop("gear/gear[1]/wow") and !getprop("gear/gear[2]/wow") and !getprop("gear/gear[3]/wow") ) {
  131. screen.log.write("Only possible on ground !!!");
  132. return;
  133. }
  134. if ( getprop("/sim/model/ec130/basket_right") ) {
  135. me.basketr.toggle();
  136. }
  137. }
  138. doors.hookexport = func {
  139. if ( getprop("/sim/model/ec130/hoist") ) {
  140. me.hook.toggle();
  141. var p = getprop("/sim/model/ec130/doors/hook/position-norm");
  142. if ( getprop("/sim/model/ec130/doors/hook/position-norm") < 0.9 ) {
  143. gui.popupTip("Hook opening ...",2);
  144. } else {
  145. gui.popupTip("Hook closing ...",2);
  146. }
  147. settimer(func { gui.popupTip("Hook " ~ (p ? "closed !" : "open !"));},2.1);
  148. }
  149. }
  150. doors.mgpuexport = func {
  151. if ( getprop("/controls/electric/external-power") ) {
  152. me.mgpu.toggle();
  153. }
  154. }
  155. # ==============
  156. # Initialization
  157. # ==============
  158. # objects must be here, otherwise local to init()
  159. doorsystem = doors.new();
  160. setprop("/sim/model/ec130/doors/door-open",0);
  161. # mhab added
  162. DoorFlagUpdate = func {
  163. if ( getprop("/sim/model/ec130/doors/luggagel/position-norm") != 0
  164. or getprop("/sim/model/ec130/doors/luggager/position-norm") != 0
  165. or getprop("/sim/model/ec130/doors/doorb/position-norm") != 0 ) {
  166. setprop("/sim/model/ec130/doors/door-open",1);
  167. } else {
  168. setprop("/sim/model/ec130/doors/door-open",0);
  169. }
  170. settimer(DoorFlagUpdate, 0.3);
  171. }
  172. DoorFlagUpdate();