Props: add defaultValue to getInt|Double Value
Simplify handling where the property value might be nil.
This commit is contained in:
parent
a395423f27
commit
e945dafca3
1 changed files with 14 additions and 4 deletions
|
@ -58,12 +58,22 @@ var Node = {
|
|||
return !!val;
|
||||
},
|
||||
|
||||
getIntValue : func {
|
||||
return math.round(me.getValue());
|
||||
getIntValue : func (defaultValue = 0) {
|
||||
var v = me.getValue();
|
||||
if (!v) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return math.round(v);
|
||||
},
|
||||
|
||||
getDoubleValue : func {
|
||||
return num(me.getValue());
|
||||
getDoubleValue : func (defaultValue = 0.0) {
|
||||
var v = me.getValue();
|
||||
if (!v) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return num(v);
|
||||
},
|
||||
|
||||
remove : func {
|
||||
|
|
Loading…
Reference in a new issue