Notifications
Clear all
[Closed] array path to controller
Feb 28, 2013 9:59 pm
Say for example I have an array that contains the numbers which represent a subAnim controller path.
I’m trying to build a function that would return the controller and node’s complete path.
How could I build a variable which would allow me to directly get to that controller.
example:
m = returnSubAnim $Teapot #(3,1,1)
print m
--printed "$Teapot[1][1]"
Working code, but I’m not a fan of execute
fn returnSubAnim obj arr =
(
local str = "$"+obj.name
for i in 1 to arr.count do append str ("[" + arr[i] as string + "]")
execute str
)
tea = teapot()
subIndexes = #(3,1,1)
clearlistener()
m = (returnSubAnim tea subIndexes)
m.value = 10
6 Replies
1 Reply
You can use also
fn returnSubAnim obj arr val: =
(
local str = "$"+obj.name
for i in 1 to arr.count do append str ("[" + arr[i] as string + "]")
m = execute str
if val != unsupplied do m.value = val
)
tea = teapot()
subIndexes = #(3,1,1)
returnSubAnim tea subIndexes val:100
Feb 28, 2013 9:59 pm
Working code, but I’m not a fan of execute
Yes I never feel comfortable using it. I’ve never understood why the scope has to be global. Why can’t it just be in the scope of the code where it’s executed?
Cg.
Feb 28, 2013 9:59 pm
seems like no matter what the execute will have to be used. I’m going to keep searching around.
1 Reply
Feb 28, 2013 9:59 pm
I’ve never heard of that. It seems rather awesome!
Thank you for sharing that!