nasal: cleanup & minor fixes
- fuel.nas: use props.initNode() - debug.nas: fix comment - globals.nas: load_nasal(): check extension and set module arg - io.nas: update log message (the rules are no longer for io.open() only)
This commit is contained in:
parent
0116c65fc4
commit
4ac84809e9
4 changed files with 14 additions and 26 deletions
|
@ -228,9 +228,8 @@ var string = func(o) {
|
|||
} elsif (t == "ghost") {
|
||||
var gt = ghosttype(o);
|
||||
if (contains(ghosttypes, gt))
|
||||
return _angle("<") ~ _nil(ghosttypes[gt]) ~ _angle(">");
|
||||
else
|
||||
return _angle("<") ~ _nil(gt) ~ _angle(">");
|
||||
gt = ghosttypes[gt];
|
||||
return _angle("<") ~ _nil(gt) ~ _angle(">");
|
||||
|
||||
} else {
|
||||
return _angle("<") ~ _vartype(t) ~ _angle(">");
|
||||
|
@ -297,8 +296,8 @@ var proptrace = func(root = "/", frames = 1) {
|
|||
# time in seconds. Examples:
|
||||
#
|
||||
# var test = func { getprop("/sim/aircraft"); }
|
||||
# debug.benchmark("test()/2", 1000, test);
|
||||
# debug.benchmark("test()/2", 1000, func setprop("/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 start = systime();
|
||||
|
|
|
@ -86,15 +86,6 @@ var loop = func {
|
|||
}
|
||||
|
||||
|
||||
var init_double_prop = func(node, prop, val) {
|
||||
if (node.getNode(prop) != nil)
|
||||
val = num(node.getNode(prop).getValue());
|
||||
|
||||
node.getNode(prop, 1).setDoubleValue(val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
var tanks = [];
|
||||
var engines = [];
|
||||
var fuel_freeze = nil;
|
||||
|
@ -117,17 +108,15 @@ _setlistener("/sim/signals/fdm-initialized", func {
|
|||
}
|
||||
|
||||
foreach (var t; props.globals.getNode("/consumables/fuel", 1).getChildren("tank")) {
|
||||
if (!size(t.getChildren()))
|
||||
if (!t.getAttribute("children"))
|
||||
continue; # skip native_fdm.cxx generated zombie tanks
|
||||
|
||||
append(tanks, t);
|
||||
init_double_prop(t, "level-gal_us", 0.0);
|
||||
init_double_prop(t, "level-lbs", 0.0);
|
||||
init_double_prop(t, "capacity-gal_us", 0.01); # not zero (div/zero issue)
|
||||
init_double_prop(t, "density-ppg", 6.0); # gasoline
|
||||
|
||||
if (t.getNode("selected") == nil)
|
||||
t.getNode("selected", 1).setBoolValue(1);
|
||||
props.initNode(t.getNode("level-gal_us", 1), 0.0);
|
||||
props.initNode(t.getNode("level-lbs", 1), 0.0);
|
||||
props.initNode(t.getNode("capacity-gal_us", 1), 0.01); # not zero (div/zero issue)
|
||||
props.initNode(t.getNode("density-ppg", 1), 6.0); # gasoline
|
||||
props.initNode(t.getNode("selected", 1), 1, "BOOL");
|
||||
}
|
||||
|
||||
loop();
|
||||
|
|
|
@ -135,7 +135,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
|
|||
var path = getprop("/sim/fg-home") ~ "/Nasal";
|
||||
if((var dir = directory(path)) == nil) return;
|
||||
foreach(var file; sort(dir, cmp))
|
||||
if(substr(file, -4) == ".nas")
|
||||
io.load_nasal(path ~ "/" ~ file);
|
||||
if(size(file) > 4 and substr(file, -4) == ".nas")
|
||||
io.load_nasal(path ~ "/" ~ file, substr(file, 0, size(file) - 4));
|
||||
});
|
||||
|
||||
|
|
|
@ -272,8 +272,8 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
|
|||
read_rules = [["*/" ~ config, 0]] ~ read_rules;
|
||||
write_rules = [["*/" ~ config, 0]] ~ write_rules;
|
||||
if (__.log_level <= 3) {
|
||||
print("io.open()/READ: ", debug.string(read_rules));
|
||||
print("io.open()/WRITE: ", debug.string(write_rules));
|
||||
print("IOrules/READ: ", debug.string(read_rules));
|
||||
print("IOrules/WRITE: ", debug.string(write_rules));
|
||||
}
|
||||
|
||||
# make safe, local copies
|
||||
|
|
Loading…
Reference in a new issue