globals: cosmetics
props: initNode(): allow nil as first arg
This commit is contained in:
parent
2abb0516b5
commit
e8a666c8e4
2 changed files with 12 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue