Notifications
Clear all

[Closed] float_script addNode/addObject not working

What’s wrong with this snippet?
I get an error when the expression is applied because the addNode doesn’t seem to have worked. I have other code that’s exactly the same (sometimes addNode, other times addObject) and it works fine. Under what circumstances do addNode & addObject not get applied. I’ve confirmed that the object assigned in addNode does exist. I’m just not sure why it’s not being inserted into the float_script.


 	if widgetType == "joystick" then		-- remember, from upper-left, clockwise: 1, 2, 3, 4
 	(
 		widgetNode = getNodeByName(widgetName)
 		print("widgetNode = " + widgetNode.name)
 		if (widgetNode != undefined) then
 		(
 			-- each morpher is limited to 100 morph targets, so we'll just zip through all to see
 			-- if there is any data in the morph.  If there is, then we'll check it's name against shapeName
 			for i=1 to 100 do
 			(	
 				morphMod = $neutral
 
 				targetName = WM3_MC_GetName morphMod.morpher i
 				
 				if targetName == shapeName then
 				(
 					expr = "widgetNode.position.controller.x_position.controller.value*100"
 					
 					fe = float_script()
 					fe.addNode "widget" widgetNode
 					fe.setExpression expr
 					
 					morphMod.morpher[i].controller = float_script()
 					
 					print("EXPRESSION: " + expr)
 				)
 			)
 		)
 	)
 
2 Replies

The error is in this part of the script:

expr = "widgetNode.position.controller.x_position.controller.value * 100"

fe = float_script()
fe.addNode "widget" widgetNode

The variable name is “widget”, but you’re using “widgetNode” in the expression. If you change that to widget it should work.

Martijn

Oh, holy crap! Thanks for spotting that. I need to stop coding when 3/4 asleep. It can only lead to stupidity.

That did it. Thanks again!

Alec