diff --git a/Nasal/globals.nas b/Nasal/globals.nas index 9e71181ac..1413a8e23 100644 --- a/Nasal/globals.nas +++ b/Nasal/globals.nas @@ -116,12 +116,11 @@ var setlistener = func(node, fn, init = 0, runtime = 1) { # error. # var defined = func(sym) { - var fn = 1; - while((var frame = caller(fn)) != nil) { - if(contains(frame[0], sym)) return 1; - fn += 1; - } - return contains(globals, sym); + if (contains(caller(1)[0], sym)) return 1; + var fn = caller(1)[1]; + for (var l=0; (var frame = closure(fn, l)) != nil; l+=1) + if (contains(frame, sym)) return 1; + return 0; } diff --git a/Nasal/local_weather/cloud_placement_lowlevel.nas b/Nasal/local_weather/cloud_placement_lowlevel.nas index bbf9554e1..ea948cf93 100644 --- a/Nasal/local_weather/cloud_placement_lowlevel.nas +++ b/Nasal/local_weather/cloud_placement_lowlevel.nas @@ -119,7 +119,7 @@ for (i=0; i< max_num_streaks; i=i+1) y = y - arg.Dy + 2.0 * rand() * arg.Dy; var flag = 0; - var bias =1.0 - (1.0* abs(i-0.5 * max_num_streaks)/max_num_streaks + 1.0* abs(j-0.5 * aspect_num_clouds)/aspect_num_clouds); + var bias =1.0 - (1.0* math.abs(i-0.5 * max_num_streaks)/max_num_streaks + 1.0* math.abs(j-0.5 * aspect_num_clouds)/aspect_num_clouds); var comp = -.25 * rnd_array[j] + 0.75 * bias; comp = comp + arg.size_bias; @@ -177,7 +177,7 @@ for (var i = 0; i