ScriptSpot

Forum topic · General Scripting

Adding Keys for noise strength position controller

By lucky_lowell · 2010-10-01

Description

Was hoping for a little insight into the syntax of creating keys for noise strength in a position controller.

What happens is I get only two keys the first and last but I can't figure out why I don't get keys for all the intermediary values.

stumped
Lowell.

Attachments
Comments (2)

Who's Better Than You!

lucky_lowell · 2010-10-01

thank you very much. I understand where I went wrong.

Lowell

Anubis · 2010-10-01

I edit your script, read the notes inside.
Also I'll add some tips to optimize the code:

-- in while loop you can convert quickly
-- your string to array of strings with filterString() function.
-- For example:
local valArray = filterString (readline files) " "
-- + even more, don't need to replace your commas in csv file,
-- so, if the data is formated as "15,0.002146667,0.002146667,0.002146667"
-- then above expression w'd be just:
local valArray = filterString (readline files) ","

-- + even more, ...
-- if you use readValue(), you never need to convert strings ;-)
local data = #()
for i = 1 to 4 do data[i] = (readValue files)

-- and next, just...
animate on at time t (...)

-- in other words, you can make your "while" loop very shorter:
while not eof files do (
    local data = #()
    for i = 1 to 4 do data[i] = (readValue files)
    animate on at time data[1] (
        applyObj.scale = [data[2],data[3],data[4]]
        applyObj.pos.controller.noise_strength = [data[2],data[3],data[4]]
    )
)
-- cheers
Attachments