From e8a666c8e47e531f8c8298cc369e0140a9ba3f65 Mon Sep 17 00:00:00 2001 From: mfranz Date: Sun, 14 Dec 2008 23:45:33 +0000 Subject: [PATCH] globals: cosmetics props: initNode(): allow nil as first arg --- Nasal/globals.nas | 6 ++---- Nasal/props.nas | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Nasal/globals.nas b/Nasal/globals.nas index 8a97293f8..41b9d01fa 100644 --- a/Nasal/globals.nas +++ b/Nasal/globals.nas @@ -6,6 +6,8 @@ var R2D = 180 / math.pi; # radian to degree var FT2M = 0.3048; # feet to meter var M2FT = 1 / FT2M; +var NM2M = 1852; # nautical miles to meter +var M2NM = 1 / NM2M; var LB2KG = 0.45359237; # pounds to kilogram var KG2LB = 1 / LB2KG; @@ -13,10 +15,6 @@ var KG2LB = 1 / LB2KG; var GAL2L = 3.785411784; # US gallons to liter var L2GAL = 1 / GAL2L; -var NM2M = 1852; # nautical miles to meter -var M2NM = 1 / NM2M; - - ## # Returns true if the first object is an instance of the second # (class) object. Example: isa(someObject, props.Node) diff --git a/Nasal/props.nas b/Nasal/props.nas index 9058cdae8..5dc965695 100644 --- a/Nasal/props.nas +++ b/Nasal/props.nas @@ -123,15 +123,17 @@ Node.getValues = func { ## # Initializes property if it's still undefined. First argument -# is a property name/path. Second argument is the default value. -# The third, optional argument is a property type (one of -# "STRING", "DOUBLE", "INT", or "BOOL"). If it is omitted, then -# "DOUBLE" is used for numbers, and STRING for everything else. -# Returns the property as props.Node. The fourth optional argument -# enforces a type if non-zero. +# is a property name/path. It can also be nil or an empty string, +# in which case the node itself gets initialized, rather than one +# of its children. Second argument is the default value. The third, +# optional argument is a property type (one of "STRING", "DOUBLE", +# "INT", or "BOOL"). If it is omitted, then "DOUBLE" is used for +# numbers, and STRING for everything else. Returns the property +# as props.Node. The fourth optional argument enforces a type if +# non-zero. # -Node.initNode = func(path = "", value = 0, type = nil, force = 0) { - var prop = me.getNode(path, 1); +Node.initNode = func(path = nil, value = 0, type = nil, force = 0) { + var prop = me.getNode(path or "", 1); if(prop.getType() != "NONE") value = prop.getValue(); if(force) prop.clearValue(); if(type == nil) prop.setValue(value);