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