use io.load_nasal() to load the local Nasal files from ~/.fgfs/Nasal/
This commit is contained in:
parent
ad781922a7
commit
8202730c4e
1 changed files with 1 additions and 16 deletions
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue