AME 394 Local Variable — Note in TouchDesigner
Published in
2 min readApr 10, 2020
Key Points :
- Local Variable
- Local Variable with CHOP
—
Local Variable
.setVar(‘variable_name’, value)
Create a “Text” (DAT operator), and writing down the codes.
me.parent().setVar(‘Height’, 720)me.parent().setVar(‘Width’, 1280)
Then, right click on the “Text” node, choosing ‘Run Script’.
It’ll automatically generate a “local” operator.
Now we have the local variables.
Let’s go to parent level. We can use it like this.
me.var(‘Height’)me.var(‘Width’)
Local Variable with CHOP
We used “LFO” (CHOP operator) in the example.
- Create “LFO” and linking it to “CHOP Execute” (DAT operator).
- Keep ‘onValueChange()’ only in the “CHOP Execute”, and checking the ‘Value Change’ is switching on.
- I used the ‘round()’ function to make the value more easy the look.
def onValueChange(channel, sampleIndex, val, prev): me.parent().setVar('LFO', round(val, 2)) return
—
This article is note about learning AME 394 by Matthew Ragan.
It’s the best TouchDesigner teacher I’ve seen.