1
0
Fork 0

Props: add defaultValue to getInt|Double Value

Simplify handling where the property value might be nil.
This commit is contained in:
James Turner 2022-03-24 11:40:14 +00:00
parent a395423f27
commit e945dafca3

View file

@ -58,12 +58,22 @@ var Node = {
return !!val; return !!val;
}, },
getIntValue : func { getIntValue : func (defaultValue = 0) {
return math.round(me.getValue()); var v = me.getValue();
if (!v) {
return defaultValue;
}
return math.round(v);
}, },
getDoubleValue : func { getDoubleValue : func (defaultValue = 0.0) {
return num(me.getValue()); var v = me.getValue();
if (!v) {
return defaultValue;
}
return num(v);
}, },
remove : func { remove : func {