From 2cf6cf4a930d9d53dd189087a7cddbeeab862c1d Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Sat, 9 Jan 2016 07:56:47 +0100 Subject: [PATCH] joystick.PropertyScaleAxis.parse(): copy the property name too - Since joystick.PropertyScaleAxis instances have a 'prop' attribute indicating the property name, it seems logical to have joystick.PropertyScaleAxis.parse() set this attribute based on the property name in its argument ('p'). - This commit also tries to improve readability by using a 'bindingNode' variable instead of repeatedly calling 'p.getNode("binding", 1)'. --- Nasal/joystick.nas | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Nasal/joystick.nas b/Nasal/joystick.nas index ba883166b..b20aea61d 100644 --- a/Nasal/joystick.nas +++ b/Nasal/joystick.nas @@ -127,13 +127,16 @@ var PropertyScaleAxis = { }, parse: func(p) { - # Don't create a null 'factor' node if it doesn't exist! + bindingNode = p.getNode("binding", 1); + me.prop = bindingNode.getNode("property", 1).getValue(); + + # Don't create an empty 'factor' node if it doesn't exist! # (value 0 wouldn't be appropriate for a default factor) - factorNode = p.getNode("binding", 1).getNode("factor", 0); + factorNode = bindingNode.getNode("factor", 0); me.factor = (factorNode != nil) ? factorNode.getValue() : 1.0; me.inverted = (me.factor < 0); - me.offset = p.getNode("binding", 1).getNode("offset", 1).getValue(); + me.offset = bindingNode.getNode("offset", 1).getValue(); }, getBinding: func(axis) {