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:
parent
8bf823c4fb
commit
71f80dff34
1 changed files with 4 additions and 2 deletions
|
@ -127,11 +127,13 @@ Node.getValues = func {
|
||||||
# The third, optional argument is a property type (one of
|
# The third, optional argument is a property type (one of
|
||||||
# "STRING", "DOUBLE", "INT", or "BOOL"). If it is omitted, then
|
# "STRING", "DOUBLE", "INT", or "BOOL"). If it is omitted, then
|
||||||
# "DOUBLE" is used for numbers, and STRING for everything else.
|
# "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);
|
var prop = me.getNode(path, 1);
|
||||||
if(prop.getType() != "NONE") value = prop.getValue();
|
if(prop.getType() != "NONE") value = prop.getValue();
|
||||||
|
if(force) prop.clearValue();
|
||||||
if(type == nil) prop.setValue(value);
|
if(type == nil) prop.setValue(value);
|
||||||
elsif(type == "DOUBLE") prop.setDoubleValue(value);
|
elsif(type == "DOUBLE") prop.setDoubleValue(value);
|
||||||
elsif(type == "INT") prop.setIntValue(value);
|
elsif(type == "INT") prop.setIntValue(value);
|
||||||
|
|
Loading…
Reference in a new issue