1
0
Fork 0

use io.load_nasal() to load the local Nasal files from ~/.fgfs/Nasal/

This commit is contained in:
mfranz 2008-07-30 19:25:27 +00:00
parent ad781922a7
commit 8202730c4e

View file

@ -136,23 +136,8 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
if((var dir = directory(path)) == nil) return;
foreach(var file; sort(dir, cmp)) {
if(substr(file, -4) != ".nas") continue;
var module = substr(file, 0, size(file) - 4);
file = path ~ "/" ~ file;
printlog("info", ">>> executing local Nasal file ", file);
if(!contains(globals, module)) var locals = globals[module] = {};
elsif(typeof(globals[module]) == "hash") var locals = globals[module];
else var locals = {};
var err = [];
var code = call(func { compile(io.readfile(file), file) }, nil, err);
if(size(err)) {
print(file ~ ": " ~ err[0]);
continue;
}
call(bind(code, globals), nil, nil, locals, err);
debug.printerror(err);
io.load_nasal(path ~ "/" ~ file);
}
});