diff --git a/Nasal/contrail.nas b/Nasal/contrail.nas index c9e93572c..2673deb1e 100644 --- a/Nasal/contrail.nas +++ b/Nasal/contrail.nas @@ -16,12 +16,12 @@ updateContrail = func{ contrail_temp_Node.setValue(con_temp); if (y < con_temp and y < -40){ - contrail_Node.setValue(1); - } else { - contrail_Node.setValue(0); - } + contrail_Node.setValue(1); + } else { + contrail_Node.setValue(0); + } - settimer(updateContrail,30) + settimer(updateContrail,30) } ### Contrail diff --git a/Nasal/controls.nas b/Nasal/controls.nas index 40abd7946..4ef317279 100644 --- a/Nasal/controls.nas +++ b/Nasal/controls.nas @@ -196,10 +196,9 @@ var stepSlats = func(step) { # magnetos, for instance), work similarly but not compatibly, and # could be integrated. # -var stepProps = func { - var dst = props.globals.getNode(arg[0]); - var array = props.globals.getNode(arg[1]); - var delta = arg[2]; +var stepProps = func(dst, array, delta) { + dst = props.globals.getNode(dst); + array = props.globals.getNode(array); if(dst == nil or array == nil) { return; } var sets = array.getChildren("setting"); @@ -238,30 +237,30 @@ var TRIM_RATE = 0.045; # events. They are *not* good for binding to the keyboard, since (at # least) X11 synthesizes its own key repeats. # -var elevatorTrim = func { - slewProp("/controls/flight/elevator-trim", arg[0] * TRIM_RATE); } -var aileronTrim = func { - slewProp("/controls/flight/aileron-trim", arg[0] * TRIM_RATE); } -var rudderTrim = func { - slewProp("/controls/flight/rudder-trim", arg[0] * TRIM_RATE); } +var elevatorTrim = func(speed) { + slewProp("/controls/flight/elevator-trim", speed * TRIM_RATE); } +var aileronTrim = func(speed) { + slewProp("/controls/flight/aileron-trim", speed * TRIM_RATE); } +var rudderTrim = func(speed) { + slewProp("/controls/flight/rudder-trim", speed * TRIM_RATE); } var THROTTLE_RATE = 0.33; -var adjThrottle = func { - adjEngControl("throttle", arg[0]); } -var adjMixture = func { - adjEngControl("mixture", arg[0]); } -var adjCondition = func { - adjEngControl("condition", arg[0]); } -var adjPropeller = func { - adjEngControl("propeller-pitch", arg[0]); } +var adjThrottle = func(speed) { + adjEngControl("throttle", speed); } +var adjMixture = func(speed) { + adjEngControl("mixture", speed); } +var adjCondition = func(speed) { + adjEngControl("condition", speed); } +var adjPropeller = func(speed) { + adjEngControl("propeller-pitch", speed); } -var adjEngControl = func { - var delta = arg[1] * THROTTLE_RATE * getprop("/sim/time/delta-realtime-sec"); +var adjEngControl = func(prop, speed) { + var delta = speed * THROTTLE_RATE * getprop("/sim/time/delta-realtime-sec"); var (value, count) = (0, 0); foreach(var e; engines) { if(e.selected.getValue()) { - var node = e.controls.getNode(arg[0], 1); + var node = e.controls.getNode(prop, 1); node.setValue(node.getValue() + delta); value += node.getValue(); # must read again because of clamping count += 1; diff --git a/Nasal/gui.nas b/Nasal/gui.nas index bc92139bd..b0e0831a1 100644 --- a/Nasal/gui.nas +++ b/Nasal/gui.nas @@ -242,11 +242,10 @@ var currTimer = 0; # API. Note especially the slightly tricky addChild() method. # var Widget = { - set : func { me.node.getNode(arg[0], 1).setValue(arg[1]); }, + set : func(name, val) { me.node.getNode(name, 1).setValue(val); }, prop : func { return me.node; }, new : func { return { parents : [Widget], node : props.Node.new() } }, - addChild : func { - var type = arg[0]; + addChild : func(type) { var idx = size(me.node.getChildren(type)); var name = type ~ "[" ~ idx ~ "]"; var newnode = me.node.getNode(name, 1); @@ -1134,9 +1133,9 @@ var showWeightDialog = func { # # # -var showHelpDialog = func { - var node = props.globals.getNode(arg[0]); - if (arg[0] == "/sim/help" and size(node.getChildren()) < 4) { +var showHelpDialog = func(path, toggle=0) { + var node = props.globals.getNode(path); + if (path == "/sim/help" and size(node.getChildren()) < 4) { node = node.getChild("common"); } @@ -1147,7 +1146,7 @@ var showHelpDialog = func { name = getprop("/sim/aircraft"); } } - var toggle = size(arg) > 1 and arg[1] != nil and arg[1] > 0; + var toggle = toggle > 0; if (toggle and contains(dialog, name)) { fgcommand("dialog-close", props.Node.new({ "dialog-name": name })); delete(dialog, name); diff --git a/Nasal/material.nas b/Nasal/material.nas index 1b3dab713..d4ad8d631 100644 --- a/Nasal/material.nas +++ b/Nasal/material.nas @@ -50,17 +50,14 @@ var dialog = nil; -var colorgroup = func { - var parent = arg[0]; # pui parent - var name = arg[1]; # "diffuse" - var base = arg[2]; - var undef = func { props.globals.getNode(base ~ name ~ "/" ~ arg[0]) == nil }; +var colorgroup = func(parent, name, base) { + var undef = func { props.globals.getNode(base ~ name ~ "/" ~ parent) == nil }; if (undef("red") and undef("green") and undef("blue")) { return 0; } - if (arg[3] != nil) { + if (base != nil) { parent.addChild("hrule").setColor(1, 1, 1, 0.5); } @@ -76,11 +73,7 @@ var colorgroup = func { } -var mat = func { - var parent = arg[0]; - var name = arg[1]; - var path = arg[2]; - var format = arg[3]; +var mat = func(parent, name, path, format, min=nil, max=nil) { if (props.globals.getNode(path) != nil) { var grp = parent.addChild("group"); grp.set("layout", "hbox"); @@ -91,9 +84,9 @@ var mat = func { var slider = grp.addChild("slider"); slider.set("property", path); slider.set("live", 1); - if (size(arg) == 6) { - slider.set("min", arg[4]); - slider.set("max", arg[5]); + if (min != nil and max != nil) { + slider.set("min", min); + slider.set("max", max); } slider.setBinding("dialog-apply"); @@ -107,8 +100,7 @@ var mat = func { } -var showDialog = func { - var base = arg[0]; +var showDialog = func(base, title=nil, x=nil, y=nil) { while (size(base) and substr(base, size(base) - 1, 1) == "/") { base = substr(base, 0, size(base) - 1); } @@ -121,14 +113,14 @@ var showDialog = func { parentdir = c ~ parentdir; } - var title = if (size(arg) > 1 and arg[1] != nil) { arg[1] } else { parentdir }; + if (title == nil) var title = parentdir; var name = "material-" ~ parentdir; base = base ~ "/"; dialog = gui.Widget.new(); dialog.set("name", name); - if (size(arg) > 2 and arg[2] != nil) { dialog.set("x", arg[2]) } - if (size(arg) > 3 and arg[3] != nil) { dialog.set("y", arg[3]) } + if (x != nil) dialog.set("x", x); + if (y != nil) dialog.set("y", y); dialog.set("layout", "vbox"); var titlebar = dialog.addChild("group"); @@ -152,7 +144,7 @@ var showDialog = func { h += colorgroup(dialog, "emission", base, h); h += colorgroup(dialog, "specular", base, h); - var undef = func { props.globals.getNode(base ~ arg[0]) == nil }; + var undef = func(prop) { props.globals.getNode(base ~ prop) == nil }; if (!(undef("shininess") and undef("transparency/alpha") and undef("threshold"))) { if (h) { dialog.addChild("hrule").setColor(1, 1, 1, 0.5);