diff --git a/Nasal/aircraft.nas b/Nasal/aircraft.nas index 64adaf417..cfa86b62c 100644 --- a/Nasal/aircraft.nas +++ b/Nasal/aircraft.nas @@ -411,8 +411,10 @@ var data = { setlistener("/sim/signals/exit", func { me._save_() }); }, load : func { - printlog("warn", "trying to load aircraft data from ", me.path, " (OK if not found)"); - io.read_properties(me.path, props.globals); + if (io.stat(me.path) != nil) { + printlog("info", "loading aircraft data from ", me.path); + io.read_properties(me.path, props.globals); + } }, save : func(v = nil) { me.loopid += 1; diff --git a/Nasal/debug.nas b/Nasal/debug.nas index 1b1b5f1e2..0a80bdf47 100644 --- a/Nasal/debug.nas +++ b/Nasal/debug.nas @@ -222,7 +222,7 @@ var string = func(o) { var k = keys(o); var s = ""; forindex (var i; k) - s ~= (i == 0 ? "" : ", ") ~ _dump_key(k[i]) ~ " : " ~ debug.string(o[k[i]]); + s ~= (i == 0 ? "" : ", ") ~ _dump_key(k[i]) ~ ": " ~ debug.string(o[k[i]]); return _brace("{") ~ " " ~ s ~ " " ~ _brace("}"); } elsif (t == "ghost") { @@ -292,17 +292,17 @@ var proptrace = func(root = "/", frames = 1) { ## -# Executes function fun with repeat times prints execution +# Executes function fn with repeat times prints execution # time in seconds. Examples: # # var test = func { getprop("/sim/aircraft"); } # debug.benchmark("test()/2", test, 1000); # debug.benchmark("test()/2", func setprop("/sim/aircraft", ""), 1000); # -var benchmark = func(label, fun, repeat = 1) { +var benchmark = func(label, fn, repeat = 1) { var start = systime(); for (var i = 0; i < repeat; i += 1) - fun(); + fn(); print(_bench(sprintf(" %s --> %.6f s ", label, systime() - start))); } @@ -315,7 +315,8 @@ var exit = func fgcommand("exit"); # code that catches "exceptions" (by a die() call or errors). The Nasal # code doesn't abort in this case. Example: # -# call(func { possibly_buggy() }, nil, var err = []); +# var possibly_buggy = func { ... } +# call(possibly_buggy, nil, var err = []); # debug.printerror(err); # var printerror = func(err) { diff --git a/Nasal/props.nas b/Nasal/props.nas index 23998c47b..4afd1a401 100644 --- a/Nasal/props.nas +++ b/Nasal/props.nas @@ -171,17 +171,17 @@ var copy = func(src, dest, attr = 0) { # Utility. Turns any ghosts it finds (either solo, or in an # array) into Node objects. # -var wrap = func { - argtype = typeof(arg[0]); +var wrap = func(node) { + var argtype = typeof(node); if(argtype == "ghost") { - return wrapNode(arg[0]); + return wrapNode(node); } elsif(argtype == "vector") { - v = arg[0]; - n = size(v); + var v = node; + var n = size(v); for(i=0; i