Debian Codegraph @

Models/Volcanoes/Surtsey/surtsey.nas

raw
1 var surtsey_ash_loop_flag = 0;
2
3 var surtsey_main_factor = 1.0;
4 var surtsey_main_probability = 0.985;
5
6 var surtsey_pos = geo.Coord.new().set_latlon(63.30510848, -20.6054166);
7
8
9 var surtsey_ash_loop = func (timer) {
10
11 if (surtsey_ash_loop_flag == 0)
12 {
13 print("Ending Surtsey ash eruption simulation.");
14 return;
15 }
16
17 if (timer < 0.0)
18 {
19
20 if (rand() > 0.6)
21 {
22 setprop("/environment/volcanoes/surtsey/ash-main-alpha", (rand() - 0.5) * 40.0);
23 setprop("/environment/volcanoes/surtsey/ash-main-beta", (rand() - 0.5) * 40.0);
24 }
25 else
26 {
27 setprop("/environment/volcanoes/surtsey/ash-main-alpha", 0.0);
28 setprop("/environment/volcanoes/surtsey/ash-main-beta", 0.0);
29 }
30 timer = 2.0 + 3.0 * rand();
31 }
32
33 var aircraft_pos = geo.aircraft_position();
34 var dist = aircraft_pos.distance_to(surtsey_pos);
35 var turbulence = 100000.0/(dist * dist);
36 if (turbulence > 1.0) {turbulence = 1.0;}
37
38 setprop("/environment/volcanoes/turbulence", turbulence);
39
40 timer = timer - 0.1;
41
42 settimer(func {surtsey_ash_loop(timer);}, 0.1);
43 }
44
45
46 surtsey_state_manager = func {
47
48 var state_main = getprop("/environment/volcanoes/surtsey/main-activity");
49
50 if ( (state_main > 1) and (surtsey_ash_loop_flag == 0))
51 {
52 print ("Starting Surtsey ash eruption simulation.");
53 surtsey_ash_loop_flag = 1;
54 surtsey_ash_loop(0.0);
55 }
56 else if ((state_main < 2) and (surtsey_ash_loop_flag == 1))
57 {
58 surtsey_ash_loop_flag = 0;
59 setprop("/environment/volcanoes/turbulence", 0);
60
61 }
62
63
64
65
66 }
67
68 # call state manager once to get correct autosaved behavior, otherwise use listener
69
70 surtsey_state_manager();
71 setlistener("/environment/volcanoes/surtsey/main-activity", surtsey_state_manager);