2017-09-24 15:08:36 +00:00
|
|
|
var puu_oo_loop_flag = 1;
|
|
|
|
|
|
|
|
var puu_oo_loop = func (strength, tgt_strength) {
|
|
|
|
|
|
|
|
if (puu_oo_loop_flag == 0)
|
|
|
|
{
|
|
|
|
print("Ending Puu Oo eruption simulation.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rand() > 0.99) {tgt_strength = 100.0;}
|
|
|
|
|
|
|
|
tgt_strength = tgt_strength - 0.5;
|
|
|
|
if (tgt_strength < 40.0) {tgt_strength = 40.0;}
|
|
|
|
|
|
|
|
var step = 5.0;
|
|
|
|
|
|
|
|
if (math.abs(strength - tgt_strength) < 5.0) {step = 1.0;}
|
|
|
|
|
|
|
|
if (strength < tgt_strength)
|
|
|
|
{strength += step;}
|
|
|
|
else
|
|
|
|
{strength -= step;}
|
|
|
|
|
|
|
|
setprop("/environment/volcanoes/kilauea/puu-oo-eruption-strength", strength);
|
|
|
|
setprop("/environment/volcanoes/kilauea/puu-oo-eruption-quantity", int(0.5*strength));
|
|
|
|
|
|
|
|
|
|
|
|
settimer(func {puu_oo_loop(strength, tgt_strength);}, 0.1);
|
|
|
|
}
|
|
|
|
|
|
|
|
puu_oo_state_manager = func {
|
|
|
|
|
2017-09-25 06:19:18 +00:00
|
|
|
#print ("Puu Oo state manager");
|
2017-09-24 15:08:36 +00:00
|
|
|
var state = getprop("/environment/volcanoes/kilauea/puu-oo-activity");
|
|
|
|
|
|
|
|
if (state == 3)
|
|
|
|
{
|
|
|
|
print("Starting Puu Oo eruption simulation.");
|
|
|
|
puu_oo_loop_flag = 1;
|
|
|
|
puu_oo_loop(50.0, 50.0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
puu_oo_loop_flag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# call state manager once to get correct autosaved behavior, otherwise use listener
|
|
|
|
|
|
|
|
puu_oo_state_manager();
|
|
|
|
|
2017-09-25 06:19:18 +00:00
|
|
|
setlistener("/environment/volcanoes/kilauea/puu-oo-activity", puu_oo_state_manager);
|