m2000-5.nas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. print("*** LOADING m2000-5.nas ... ***");
  2. ################################################################################
  3. #
  4. # m2005-5's SYSTEMS SETTINGS
  5. #
  6. ################################################################################
  7. #
  8. # Typhonn systems
  9. # crazy dj nasal from many sources...
  10. # and also, almursi work
  11. # and 5H1N0B1
  12. var deltaT = 1.0;
  13. var Elapsed_time_Seconds = 0;
  14. var Elapsed_time_previous = 0;
  15. var LastTime = 0;
  16. # Elapsed for time > 0.25 sec
  17. var Elapsed = 0;
  18. var myErr = [];
  19. var myFramerate = {a:0,b:0,c:0,d:0,e:0,f:0};#a = 0.1, b=0.2, c = 0.5, d=1, e=1.5 ; f = 2
  20. var EjectionKey = 0;
  21. var msgB = "Please land before changing payload.";
  22. #====== OBJECT CREATION =======
  23. # Need some simplification in the way to manage the interval
  24. #var RDM=radar.Radar.new(NewRangeTab:[10, 20, 40, 60],NewRangeIndex:1,NewHaveDoppler:0,forcePath:"instrumentation/radar2/targets",NewAutoUpdate:1);
  25. #var RDM_DOPPLER_MODE=radar.Radar.new(NewRangeTab:[5, 10, 15, 20],NewRangeIndex:1,NewHaveDoppler:1,forcePath:"instrumentation/radar2/targets",NewAutoUpdate:1);
  26. #var RDI
  27. #var RDY
  28. var myRadar3 = radar.Radar.new(NewRangeTab:[10, 20, 40, 60, 160], NewRangeIndex:1, forcePath:"instrumentation/radar2/targets", NewAutoUpdate:1);
  29. #var LaserDetection = radar.Radar.new(NewRangeTab:[20], NewVerticalAzimuth:180, NewRangeIndex:0, NewTypeTarget:["aircraft", "multiplayer", "carrier", "ship", "missile", "aim120", "aim-9"], NewRadarType:"laser", NewhaveSweep:0, NewAutoUpdate:0, forcePath:"instrumentation/radar2/targets");
  30. setprop("/instrumentation/radar/az-fieldCenter", 0);
  31. var hud_pilot = hud.HUD.new({"node": "revi.canvasHUD", "texture": "hud.png"});
  32. # var rwr = hud.HUD.new({"node": "canvasRWR", "texture": "hud.png"});
  33. var prop = "payload/armament/fire-control";
  34. var actuator_fc = compat_failure_modes.set_unserviceable(prop);
  35. FailureMgr.add_failure_mode(prop, "Fire control", actuator_fc);
  36. var MirageBingo = nil;
  37. ############################################################
  38. # Global loop function
  39. # If you need to run nasal as loop, add it in this function
  40. ############################################################
  41. var global_system_loop = func{
  42. mirage2000.weather_effects_loop();
  43. }
  44. #===============================
  45. var InitListener = setlistener("/sim/signals/fdm-initialized", func() {
  46. main_Init_Loop();
  47. removelistener(InitListener);
  48. });
  49. # Main init loop
  50. # Perhaps in the future, make an object for each subsystems, in the same way
  51. # of "engine"
  52. var main_Init_Loop = func()
  53. {
  54. # Loop Updated inside
  55. #print("Electrical ... Check");
  56. electrics.Electrical_init();
  57. # Loop Updated inside
  58. #print("Fuel ... Check");
  59. #fuel.Fuel_init();
  60. # Loop Updated below
  61. # print("Stability Augmentation System ... Check");
  62. # mirage2000.init_SAS();
  63. print("Intrumentation ... Check");
  64. instrumentation.initIns();
  65. print("Radar ... Check");
  66. myRadar3.init();
  67. #LaserDetection.init();
  68. print("Flight Director ... Check");
  69. mirage2000.init_set();
  70. #print("MFD ...Check");
  71. #mirage2000.mfd_update_main();
  72. print("Transponder ... Check");
  73. init_Transpondeur();
  74. print("blackout ... Check");
  75. blackout.blackout_init();
  76. print("HUD canvas...Check");
  77. hud_pilot.update();
  78. print("MFD ... Check");
  79. mirage2000.setCentralMFD();
  80. if(getprop("/instrumentation/efis/Mode"))
  81. {
  82. mirage2000.mdfselection();
  83. }
  84. print("Missile view Check");
  85. view.init_missile_view();
  86. environment.environment();
  87. #Should be replaced by an object creation
  88. #settimer(func(){mirage2000.createMap();},10);
  89. MirageBingo = instrumentation.bingo.new();
  90. MirageBingo.update();
  91. print("system loop ... Check");
  92. UpdateMain();
  93. }
  94. var UpdateMain = func
  95. {
  96. settimer(mirage2000.updatefunction, 0);
  97. }
  98. #This update function needs to be re-done properly
  99. var updatefunction = func()
  100. {
  101. AbsoluteTime = getprop("/sim/time/elapsed-sec");
  102. #Things to update, order by refresh rate.
  103. var AP_Alt = getprop("/autopilot/locks/altitude");
  104. ########################### rate 0
  105. # mirage2000.Update_SAS(); #we need to check what is still here, and what we can convert in xml
  106. # if (getprop("payload/armament/es/flags/deploy-id-10")!= nil) {
  107. # setprop("instrumentation/ejection/force", 7-5*getprop("payload/armament/es/flags/deploy-id-10"));
  108. # } else {
  109. # setprop("instrumentation/ejection/force", 7);
  110. # }
  111. # Flight Director (autopilot)
  112. if(getprop("/autopilot/locks/AP-status") == "AP1")
  113. {
  114. call(mirage2000.update_fd,nil,nil,nil, myErr= []);
  115. if(size(myErr)>0){
  116. foreach(var i;myErr) {
  117. print(i);
  118. }
  119. }
  120. }
  121. instrumentation.stallwarning();
  122. ################## Rate 0.1 ##################
  123. if(AbsoluteTime - myFramerate.a > 0.05){
  124. #call(hud_pilot.update,nil,nil,nil, myErr);
  125. hud_pilot.update();
  126. call(mirage2000.theShakeEffect,nil,nil,nil, myErr);
  127. mirage2000.mfd_update_main();
  128. myFramerate.a = AbsoluteTime;
  129. mirage2000.Intake_pelles();
  130. }
  131. ################## rate 0.5 ###############################
  132. if(AbsoluteTime - myFramerate.c > 0.5)
  133. {
  134. #call(m2000_load.Encode_Load,nil,nil,nil, myErr);
  135. call(m2000_mp.Encode_Bool,nil,nil,nil, myErr);
  136. myFramerate.c = AbsoluteTime;
  137. #if(getprop("autopilot/settings/tf-mode")){ <- need to find what is enabling it
  138. #8 second prevision do not need to be updated each fps
  139. if(AP_Alt =="TF"){
  140. call(mirage2000.tfs_radar,nil,nil,nil, myErr= []);
  141. if(size(myErr)) {
  142. foreach(var i;myErr) {
  143. print(i);
  144. }
  145. }
  146. }
  147. mp_messaging();
  148. MirageBingo.update();
  149. #mirage2000.weather_effects_loop();
  150. #environment.environment();
  151. # call(environment.low_loop,nil,nil,nil, myErr);
  152. # if(size(myErr)>0){
  153. # #debug.printerror(myErr);
  154. # }
  155. }
  156. ###################### rate 1 ###########################
  157. if(AbsoluteTime - myFramerate.d > 1)
  158. {
  159. #call(mirage2000.fuel_managment,nil,nil,nil, myErr);
  160. if(getprop("/autopilot/locks/AP-status") != "AP1"){
  161. call(mirage2000.update_fd,nil,nil,nil, myErr= []);
  162. if(size(myErr)>0){
  163. foreach(var i;myErr) {
  164. print(i);
  165. }
  166. }
  167. }
  168. myFramerate.d = AbsoluteTime;
  169. }
  170. ###################### rate 1.5 ###########################
  171. if(AbsoluteTime - myFramerate.e > 1.5)
  172. {
  173. call(environment.environment,nil,nil,nil, myErr);
  174. if(size(myErr)>0){
  175. #debug.printerror(myErr);
  176. }
  177. call(environment.max_cloud_layer,nil,nil,nil, myErr);
  178. if(size(myErr)>0){
  179. #debug.printerror(myErr);
  180. }
  181. myFramerate.e = AbsoluteTime;
  182. }
  183. ###################### rate 2 ###########################
  184. if(AbsoluteTime - myFramerate.f > 2)
  185. {
  186. if(AP_Alt =="TF"){
  187. call(mirage2000.long_view_avoiding,nil,nil,nil, myErr);
  188. if(size(myErr)>0){
  189. foreach(var i;myErr) {
  190. print(i);
  191. }
  192. }
  193. }
  194. myFramerate.f = AbsoluteTime;
  195. }
  196. # Update at the end
  197. call(mirage2000.UpdateMain,nil,nil,nil, myErr);
  198. }
  199. var init_Transpondeur = func()
  200. {
  201. # Init Transponder
  202. var poweroften = [1, 10, 100, 1000];
  203. var idcode = getprop('/instrumentation/transponder/id-code');
  204. if(idcode != nil)
  205. {
  206. for(var i = 0 ; i < 4 ; i += 1)
  207. {
  208. setprop("/instrumentation/transponder/inputs/digit[" ~ i ~ "]", int(math.mod(idcode / poweroften[i], 10)));
  209. }
  210. }
  211. }
  212. controls.deployChute = func(v)
  213. {
  214. # Deploy
  215. if(v > 0)
  216. {
  217. setprop("controls/flight/chute_deployed", 1);
  218. setprop("controls/flight/chute_open", 1);
  219. chuteAngle();
  220. }
  221. # Jettison
  222. if(v < 0)
  223. {
  224. var voltage = getprop("systems/electrical/outputs/chute_jett");
  225. if(voltage > 20)
  226. {
  227. setprop("controls/flight/chute_jettisoned", 1);
  228. setprop("controls/flight/chute_open", 0);
  229. }
  230. }
  231. }
  232. var chuteAngle = func
  233. {
  234. var chute_open = getprop('controls/flight/chute_open');
  235. if(chute_open != '1')
  236. {
  237. return();
  238. }
  239. var speed = getprop('/velocities/airspeed-kt');
  240. var aircraftpitch = getprop('/orientation/pitch-deg[0]');
  241. var aircraftyaw = getprop('/orientation/side-slip-deg');
  242. var chuteyaw = getprop("orientation/chute_yaw");
  243. var aircraftroll = getprop('/orientation/roll-deg');
  244. if(speed > 210)
  245. {
  246. setprop("controls/flight/chute_jettisoned", 1); # Model Shear Pin
  247. return();
  248. }
  249. # Chute Pitch
  250. var chutepitch = aircraftpitch * -1;
  251. setprop("orientation/chute_pitch", chutepitch);
  252. # Damped yaw from Vivian's A4 work
  253. var n = 0.01;
  254. if(aircraftyaw == nil)
  255. {
  256. aircraftyaw = 0;
  257. }
  258. if(chuteyaw == nil)
  259. {
  260. chuteyaw = 0;
  261. }
  262. var chuteyaw = (aircraftyaw * n) + (chuteyaw * (1 - n));
  263. setprop("orientation/chute_yaw", chuteyaw);
  264. # Chute Roll - no twisting for now
  265. var chuteroll = aircraftroll;
  266. setprop("orientation/chute_roll", chuteroll * rand() * -1);
  267. return registerTimerControlsNil(chuteAngle); # Keep watching
  268. }
  269. var chuteRepack = func
  270. {
  271. setprop('controls/flight/chute_open', 0);
  272. setprop('controls/flight/chute_deployed', 0);
  273. setprop('controls/flight/chute_jettisoned', 0);
  274. }
  275. var fuel_managment = func()
  276. {
  277. var Externaltank = getprop("/consumables/fuel/tank[2]/empty");
  278. Externaltank *= getprop("/consumables/fuel/tank[3]/empty");
  279. Externaltank *= getprop("/consumables/fuel/tank[4]/empty");
  280. # If only one external Tank is still not empty, then...
  281. # systems/refuel/contact = false si pas refuel en cours
  282. if(getprop("/systems/refuel/contact"))
  283. {
  284. setprop("/consumables/fuel/tank[0]/selected", 1);
  285. setprop("/consumables/fuel/tank[1]/selected", 1);
  286. if(getprop("/consumables/fuel/tank[2]/capacity-m3") != 0)
  287. {
  288. setprop("/consumables/fuel/tank[2]/selected", 1);
  289. }
  290. if(getprop("/consumables/fuel/tank[3]/capacity-m3") != 0)
  291. {
  292. setprop("/consumables/fuel/tank[3]/selected", 1);
  293. }
  294. if(getprop("/consumables/fuel/tank[4]/capacity-m3") != 0)
  295. {
  296. setprop("/consumables/fuel/tank[4]/selected", 1);
  297. }
  298. }
  299. elsif(Externaltank)
  300. {
  301. setprop("/consumables/fuel/tank[0]/selected", 1);
  302. setprop("/consumables/fuel/tank[1]/selected", 1);
  303. }
  304. else
  305. {
  306. setprop("/consumables/fuel/tank[0]/selected", 0);
  307. setprop("/consumables/fuel/tank[1]/selected", 0);
  308. if(getprop("/consumables/fuel/tank[2]/level-kg") > 0)
  309. {
  310. setprop("/consumables/fuel/tank[2]/selected", 1);
  311. }
  312. if(getprop("/consumables/fuel/tank[3]/level-kg") > 0)
  313. {
  314. setprop("/consumables/fuel/tank[3]/selected", 1);
  315. }
  316. if(getprop("/consumables/fuel/tank[4]/level-kg") > 0)
  317. {
  318. setprop("/consumables/fuel/tank[4]/selected", 1);
  319. }
  320. }
  321. }
  322. # 5H1N0B1's NOTE : Shake Effect : Taken to the 707 :
  323. #######################################################################################
  324. # Lake of Constance Hangar :: M.Kraus
  325. # Boeing 707 for Flightgear February 2014
  326. # This file is licenced under the terms of the GNU General Public Licence V2 or later
  327. #######################################################################################
  328. ############################ roll out and shake effect ##################################
  329. var shakeEffect2000 = props.globals.initNode("controls/cabin/shake-effect", 0, "BOOL");
  330. var shake2000 = props.globals.initNode("controls/cabin/shaking", 0, "DOUBLE");
  331. var theShakeEffect = func() {
  332. #ge_a_r = getprop("sim/multiplay/generic/float[1]") or 0;
  333. rSpeed = getprop("/velocities/airspeed-kt") or 0;
  334. var G = getprop("/accelerations/pilot-g");
  335. var alpha = getprop("/orientation/alpha-deg");
  336. var mach = getprop("velocities/mach");
  337. var wow = getprop("/gear/gear[1]/wow");
  338. var gun = getprop("controls/armament/Gun_trigger");
  339. var myTime = getprop("/sim/time/elapsed-sec");
  340. #sf = ((rSpeed / 500000 + G / 25000 + alpha / 20000 ) / 3) ;
  341. # I want to find a way to improve vibration amplitude with sf, but to tired actually to make it.
  342. if(shakeEffect2000.getBoolValue() and (((G > 9 or alpha > 25) and rSpeed > 30) or (mach > 0.99 and mach < 1.01) or (wow and rSpeed > 100) or gun))
  343. {
  344. #print("it is working.");
  345. setprop("controls/cabin/shaking", math.sin(48 * myTime) / 333.333);
  346. }
  347. else
  348. {
  349. setprop("controls/cabin/shaking", 0);
  350. }
  351. }
  352. var setCentralMFD = func() {
  353. setprop("/instrumentation/efis/Mode", 1);
  354. if(getprop("/instrumentation/efis/Mode"))
  355. {
  356. mirage2000.mdfselection();
  357. }
  358. }
  359. # to prevent dynamic view to act like helicopter due to defining <rotors>:
  360. dynamic_view.register(func {me.default_plane();});
  361. var test = func(){
  362. if(! contains(globals, "m2000_mp"))
  363. {
  364. var err = [];
  365. var myTree = props.globals.getNode("/sim");
  366. var raw_list = myTree.getChildren();
  367. foreach(var c ; raw_list)
  368. {
  369. if(c.getName() == "fg-aircraft"){
  370. myAircraftTree = "/sim/" ~ c.getName()~"["~c.getIndex()~"]";
  371. print(myAircraftTree);
  372. var err = [];
  373. var file = getprop(myAircraftTree) ~ "/Mirage-2000/Nasal/MP.nas";
  374. print(file);
  375. var code = call(func compile(io.readfile(file), file), nil, err);
  376. print("Path 0. Error : " ~size(err));
  377. if(size(err) == 0)
  378. {
  379. call(func {io.load_nasal(file, "m2000_mp");},nil, err);
  380. if (size(err)) {
  381. print("Path 0a. Error : ");
  382. foreach(lin;err) print(lin);
  383. }else{
  384. break;}
  385. }else {
  386. print("Path 0b. Error : ");
  387. foreach(lin;err) print(lin);
  388. }
  389. }
  390. }
  391. }
  392. }
  393. var mp_messaging = func(){
  394. if(getprop("/payload/armament/msg")){
  395. #call(func{fgcommand('dialog-close', multiplayer.dialog.dialog.prop())},nil,var err= []);# props.Node.new({"dialog-name": "location-in-air"}));
  396. call(func{multiplayer.dialog.del();},nil,var err= []);
  397. if (!getprop("/gear/gear[0]/wow")) {
  398. #call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "map"}))},nil,var err2 = []);
  399. #call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "map-canvas"}))},nil,var err2 = []);
  400. call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "WeightAndFuel"}))},nil,var err2 = []);
  401. call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "system-failures"}))},nil,var err2 = []);
  402. call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "instrument-failures"}))},nil,var err2 = []);
  403. }
  404. setprop("sim/freeze/fuel",0);
  405. setprop("/sim/freeze/master", 0);
  406. setprop("/sim/freeze/clock", 0);
  407. setprop("/sim/speed-up", 1);
  408. setprop("/gui/map/draw-traffic", 0);
  409. setprop("/sim/gui/dialogs/map-canvas/draw-TFC", 0);
  410. setprop("/sim/rendering/als-filters/use-filtering", 1);
  411. setprop("/controls/SAS/activated", 1);
  412. setprop("/sim/view[100]/enabled", 0);
  413. }
  414. }
  415. var ejection = func(){
  416. print("Ejection");
  417. if (getprop("instrumentation/ejection/done")==1) {
  418. return;
  419. }
  420. EjectionKey = EjectionKey +1;
  421. print("EjectionKey:"~EjectionKey);
  422. if(EjectionKey<3){
  423. settimer(mirage2000.init_EjectionKey, 2.0);
  424. return;
  425. }
  426. setprop("instrumentation/ejection/done",1);
  427. var es = armament.AIM.new(10, "es","gamma", nil ,[-3.65,0,0.7]);
  428. es.releaseAtNothing();
  429. view.view_firing_missile(es);
  430. setprop("sim/view[0]/enabled",0);
  431. # settimer(func {crash.exp();},3.5);
  432. }
  433. var init_EjectionKey = func(){
  434. EjectionKey = 0;
  435. }
  436. var flightmode = func (){
  437. #print("Called");
  438. if(getprop("/sim/current-view/view-number-raw") == 0) {
  439. if(getprop("/instrumentation/flightmode/app")){
  440. setprop("/sim/current-view/x-offset-m",0);
  441. setprop("/sim/current-view/y-offset-m",0.1019);
  442. setprop("/sim/current-view/z-offset-m",-2.9);
  443. setprop("/sim/current-view/field-of-view",83);
  444. }elsif(getprop("/instrumentation/flightmode/to")){
  445. setprop("/sim/current-view/x-offset-m",0);
  446. setprop("/sim/current-view/y-offset-m",0.1019);
  447. setprop("/sim/current-view/z-offset-m",-2.9);
  448. setprop("/sim/current-view/field-of-view",83);
  449. }elsif(getprop("/instrumentation/flightmode/nav")){
  450. setprop("/sim/current-view/x-offset-m",0);
  451. setprop("/sim/current-view/y-offset-m",0.025);
  452. setprop("/sim/current-view/z-offset-m",-2.9);
  453. setprop("/sim/current-view/field-of-view",83);
  454. }elsif(getprop("/instrumentation/flightmode/arm")){
  455. setprop("/sim/current-view/x-offset-m",0);
  456. setprop("/sim/current-view/y-offset-m",0.099);
  457. setprop("/sim/current-view/z-offset-m",-2.67);
  458. setprop("/sim/current-view/field-of-view",70);
  459. }else{
  460. setprop("/sim/current-view/x-offset-m",0);
  461. setprop("/sim/current-view/y-offset-m",0.025);
  462. setprop("/sim/current-view/z-offset-m",-2.9);
  463. setprop("/sim/current-view/field-of-view",83);
  464. }
  465. }
  466. gui.dialog_update("flightmode");
  467. }
  468. var call_flightmode = func(calling){
  469. #This function is made to auto switch flight mode when masterarm is switched or gear is switched
  470. var app=0;
  471. var to=0;
  472. var nav=0;
  473. var arm=0;
  474. if(calling == "m"){
  475. if(getprop("controls/armament/master-arm")==1){
  476. arm = 1;
  477. }else{
  478. nav = 1;
  479. }
  480. }elsif(calling == "g"){nav = 1;
  481. }elsif(calling == "G"){to = 1;}
  482. ## if(getprop("controls/gear/gear-down")){
  483. # to = 1;
  484. # }else{
  485. # nav = 1;
  486. # }
  487. # }
  488. setprop("/instrumentation/flightmode/app",app);
  489. setprop("/instrumentation/flightmode/to",to);
  490. setprop("/instrumentation/flightmode/nav",nav);
  491. setprop("/instrumentation/flightmode/arm",arm);
  492. flightmode();
  493. hud_pilot.recalculateLadder();
  494. }
  495. var quickstart = func() {
  496. settimer(func {
  497. setprop("controls/engines/engine[0]/cutoff",0);
  498. setprop("engines/engine[0]/out-of-fuel",0);
  499. setprop("engines/engine[0]/cutoff",0);
  500. setprop("fdm/jsbsim/propulsion/starter_cmd",1);
  501. setprop("fdm/jsbsim/propulsion/cutoff_cmd",1);
  502. setprop("fdm/jsbsim/propulsion/set-running",0);
  503. }, 0.2);
  504. }
  505. autostart = func{
  506. if(getprop("sim/time/elapsed-sec") < 10)
  507. {
  508. return;
  509. }
  510. long_starting();
  511. return; # this is a dirty and lazy way of doing it
  512. if(!getprop("/controls/engines/engine[0]/cutoff"))
  513. {
  514. me.autostart_status = 0;
  515. # Cut Off
  516. setprop("/controls/switches/hide-cutoff", 1);
  517. setprop("/controls/engines/engine/cutoff", 1);
  518. }
  519. else
  520. {
  521. setprop("/controls/engines/engine[0]/cutoff",1);
  522. # Place here all the switch 'on' needed for the autostart
  523. # First electrics switchs
  524. setprop("/controls/switches/battery-switch", 1);
  525. setprop("/controls/switches/transformator-switch", 1);
  526. setprop("/controls/switches/ALT1-switch", 1);
  527. setprop("/controls/switches/ALT2-switch", 1);
  528. # Launching process
  529. # Cut Off
  530. setprop("/controls/switches/hide-cutoff", 0);
  531. setprop("/controls/engines/engine/cutoff", 0);
  532. # Fuel Pumps
  533. setprop("/controls/switches/pump-BPG", 1);
  534. setprop("/controls/switches/pump-BPD", 1);
  535. # This isn't a pump, but it's here is the starting process.
  536. # Vent is to clear fuel of the engine, allumage is to burn it.
  537. # So 1 is allumage 0 vent.
  538. setprop("/controls/switches/vent-allumage", 1);
  539. setprop("/controls/switches/pump-BP", 1);
  540. setprop("/controls/switches/hide-starter",1);
  541. setprop("/controls/engines/engine/starter",1);
  542. mystarter();
  543. }
  544. }
  545. var long_starting = func(){
  546. #Closing the diloag
  547. call(func{fgcommand('dialog-close', props.Node.new({"dialog-name": "config"}))},nil,var err2 = []);
  548. #Placing the view on take off view
  549. if(getprop("/sim/current-view/view-number-raw") == 0) {
  550. setprop("/sim/current-view/x-offset-m",0);
  551. setprop("/sim/current-view/y-offset-m",0.1019);
  552. setprop("/sim/current-view/z-offset-m",-2.9);
  553. setprop("/sim/current-view/field-of-view",83);
  554. #zooming on fuel, electrics and alerts
  555. setprop("/sim/current-view/pitch-offset-deg",-40);
  556. setprop("/sim/current-view/heading-offset-deg",338);
  557. setprop("/sim/current-view/field-of-view",36);
  558. }
  559. settimer(func {
  560. setprop("/controls/switches/battery-switch",1);
  561. }, 3);
  562. settimer(func {
  563. setprop("/controls/switches/transformator-switch",1);
  564. }, 4);
  565. settimer(func {
  566. setprop("/controls/switches/ALT1-switch",1);
  567. setprop("/controls/switches/ALT2-switch",1);
  568. }, 4);
  569. #Zooming on starting panel
  570. settimer(func {
  571. if(getprop("/sim/current-view/view-number-raw") == 0) {
  572. setprop("/sim/current-view/pitch-offset-deg",-62);
  573. setprop("/sim/current-view/heading-offset-deg",312);
  574. setprop("/sim/current-view/field-of-view",21.6);
  575. }
  576. }, 5);
  577. # Cut Off
  578. settimer(func {
  579. setprop("/controls/switches/hide-cutoff", 1);
  580. }, 5);
  581. settimer(func {
  582. setprop("/controls/engines/engine/cutoff", 0);
  583. }, 6);
  584. settimer(func {
  585. setprop("/controls/switches/hide-cutoff", 0);
  586. }, 7);
  587. # Fuel Pumps
  588. settimer(func {
  589. setprop("/controls/switches/pump-BPG", 1);
  590. }, 8);
  591. settimer(func {
  592. setprop("/controls/switches/pump-BPD", 1);
  593. }, 9);
  594. # This isn't a pump, but it's here is the starting process.
  595. # Vent is to clear fuel of the engine, allumage is to burn it.
  596. # So 1 is allumage 0 vent.
  597. settimer(func {
  598. setprop("/controls/switches/vent-allumage", 1);
  599. }, 10);
  600. settimer(func {
  601. setprop("/controls/switches/hide-starter",1);
  602. setprop("/controls/switches/pump-BP", 1);
  603. }, 11);
  604. #Starting the engine
  605. settimer(func {
  606. setprop("/controls/engines/engine/starter",1);
  607. mystarter();
  608. }, 13);
  609. #zooming on fuel, electrics and alerts
  610. settimer(func {
  611. if(getprop("/sim/current-view/view-number-raw") == 0) {
  612. setprop("/sim/current-view/pitch-offset-deg",-38);
  613. setprop("/sim/current-view/heading-offset-deg",338);
  614. setprop("/sim/current-view/field-of-view",36);
  615. }
  616. }, 15);
  617. #puting back the view on take off view
  618. settimer(func {
  619. if(getprop("/sim/current-view/view-number-raw") == 0) {
  620. setprop("/sim/current-view/pitch-offset-deg",-14);
  621. setprop("/sim/current-view/heading-offset-deg",0);
  622. setprop("/sim/current-view/field-of-view",83);
  623. }
  624. }, 45);
  625. #turning on the air conditioning
  626. setprop("/controls/ventilation/airconditioning-enabled",1);
  627. setprop("/environment/aircraft-effects/cabin-heat-set",1);
  628. setprop("/environment/aircraft-effects/cabin-air-set",1);
  629. setprop("/controls/ventilation/windshield-hot-air-knob",1);
  630. }
  631. # #This is the starup listener. It will put a value into n1 and n2 in order start jsbsim engine without playing with cutoff
  632. #var starterlistener = setlistener("/controls/engines/engine/starter", func() {
  633. # var starterlistener = setlistener("/fdm/jsbsim/propulsion/starter_cmd", func() {
  634. var mystarter = func(){
  635. if(getprop("/fdm/jsbsim/propulsion/engine/n1")<0.5 and getprop("/fdm/jsbsim/propulsion/engine/n2")<0.5
  636. and getprop("/controls/switches/pump-BP") and getprop("/controls/switches/vent-allumage")){
  637. setprop("/fdm/jsbsim/propulsion/engine/n1",1);
  638. setprop("/fdm/jsbsim/propulsion/engine/n2",25);
  639. setprop("engines/engine[0]/out-of-fuel",0);
  640. }
  641. print("You are starting the mirage, dude");
  642. #});
  643. }
  644. setprop("consumables/fuel/tank[8]/capacity-gal_us",0);
  645. setprop("consumables/fuel/tank[9]/capacity-gal_us",0);
  646. setprop("consumables/fuel/tank[10]/capacity-gal_us",0);
  647. setprop("consumables/fuel/tank[11]/capacity-gal_us",0);
  648. setprop("consumables/fuel/tank[12]/capacity-gal_us",0);