1
0
Fork 0

initNode: add fourth optional parameter: "force", which enforces a type,

so n.initNode("whatever", 1 "BOOL", 1);  will make node n a BOOL even
if it was "DOUBLE" before. Default: 0. An existing value will be retained,
though.
This commit is contained in:
mfranz 2008-12-04 11:30:44 +00:00
parent 8bf823c4fb
commit 71f80dff34

View file

@ -127,11 +127,13 @@ Node.getValues = func {
# 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.
# Returns the property as props.Node. The fourth optional argument
# enforces a type if non-zero.
#
Node.initNode = func(path = "", value = 0, type = nil) {
Node.initNode = func(path = "", value = 0, type = nil, force = 0) {
var prop = me.getNode(path, 1);
if(prop.getType() != "NONE") value = prop.getValue();
if(force) prop.clearValue();
if(type == nil) prop.setValue(value);
elsif(type == "DOUBLE") prop.setDoubleValue(value);
elsif(type == "INT") prop.setIntValue(value);