PDA

View Full Version : float_script addNode/addObject not working


ACFred
03-13-2009, 06:45 PM
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)
)
)
)
)

magicm
03-14-2009, 06:26 PM
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

ACFred
03-16-2009, 07:31 PM
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

CGTalk Moderation
03-16-2009, 07:31 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.