F-8E-Crusader from the GRTux Hangar team.
[fg:toms-fgdata.git] / Aircraft / F-8E-Crusader / Systems / terrain.nas
1
2 var min_carrier_alt = 2;
3
4 terrain_survol = func {
5
6 var lat = getprop("/position/latitude-deg");
7 var lon = getprop("/position/longitude-deg");
8 var info = geodinfo(lat, lon);
9
10
11
12
13  if (info != nil) {
14     if (info[0] != nil){
15        setprop("/environment/terrain-hight",info[0]);
16 #var terrain_hight = info[0];
17 #print("TERRAIN ",terrain_hight);
18     }
19     if (info[1] != nil){
20       if (info[1].solid !=nil){
21         setprop("/environment/terrain-undefined",0);
22         setprop("/environment/terrain-solid",info[1].solid);
23 #var solid = info[1].solid;
24 #print("SOLID ",solid);
25
26     }
27       if (info[1].light_coverage !=nil)
28        setprop("/environment/terrain-light-coverage",info[1].light_coverage);
29       if (info[1].load_resistance !=nil)
30        setprop("/environment/terrain-load-resistance",info[1].load_resistance);
31       if (info[1].friction_factor !=nil)
32        setprop("/environment/terrain-friction-factor",info[1].friction_factor);
33       if (info[1].bumpiness !=nil)
34        setprop("/environment/terrain-bumpiness",info[1].bumpiness);
35       if (info[1].rolling_friction !=nil)
36        setprop("/environment/terrain-rolling-friction",info[1].rolling_friction);
37       if (info[1].names !=nil)
38        setprop("/environment/terrain-names",info[1].names[0]);
39
40 #unfortunately when on carrier the info[1]  is nil,  only info[0] is valid
41 #var terrain_name = info[1].names[0];
42 #print("NAME ",terrain_name);
43       #if (terrain_name == "Ocean" and terrain_hight >  min_carrier_alt)
44         #setprop("/environment/terrain-oncarrier",1);
45     }else{
46 setprop("/environment/terrain-undefined",1);
47 }
48               #debug.dump(geodinfo(lat, lon));
49
50
51   }else {
52     setprop("/environment/terrain-hight",0);
53     setprop("/environment/terrain-solid",1);
54     setprop("/environment/terrain-oncarrier",0);
55     setprop("/environment/terrain-light-coverage",1);
56     setprop("/environment/terrain-load-resistance",1e+30);
57     setprop("/environment/terrain-friction-factor",1);
58     setprop("/environment/terrain-bumpiness",0);
59     setprop("/environment/terrain-rolling-friction",0.02);
60     setprop("/environment/terrain-names","unknown");
61     }
62
63 settimer (terrain_survol, 0.1);
64 }
65
66 var window_lhb = screen.window.new(nil, -180, 2, 2000);
67
68 var fg = getprop("/sim/version/flightgear");    print ("FGVER ",fg);
69 var model_min = getprop("/sim/model/fg-ver_min");    print ("MODELmin ",model_min);
70 var model_max = getprop("/sim/model/fg-ver_max");    print ("MODELmax ",model_max);
71 var fgn1 = substr(fg,0,1);
72 var fgn3 = substr(fg,3,1);
73
74 #print ("FGN1     ",fgn1);
75 #print ("FGN3     ",fgn3);
76
77 if (fgn3  == ".") {
78 #print ("POINT");
79 var fgn2 = substr(fg,2,1);
80 var nfg = (fgn2/100)+fgn1;
81 #print ("FGVER ",nfg);
82 }
83 elsif (fgn3  != ".") {
84 #print ("NOTPOINT");
85 var fgn2 = substr(fg,2,2);
86 var nfg = (fgn2/100)+fgn1;
87 #print ("FGVER ",nfg);
88 }
89
90
91 #var diff_min = cmp(fg,model_min);    print ("DIFFSTRINGn ",diff_min);
92 #var diff_max = cmp(fg,model_max);    print ("DIFFSTRINGx ",diff_max);
93 #if (diff_min == -1 or diff_max == 1){
94
95
96 if (nfg < model_min  or  nfg > model_max){
97 setprop("fdm/simulation/wrg-ver",1);
98 window_lhb.write("WRONG FLIGHTGEAR VERSION");
99 window_lhb.write("YOU WANT AT LEAST FG VERSION IN THE RANGE : " "MIN "~ model_min ~" MAX "~model_max);
100 }else{
101 setprop("fdm/simulation/wrg-ver",0);
102 terrain_survol();
103 }
104