Moviefilein: Play driven by Switch Index Value

Hey everyone.

Another noob here…

I have a few moviefilein TOPs running into a switch TOP.
The aim is for the movie to play only when the switch index shows a certain value, and to pause in that spot if another value is shown.

I’ve been trying to add something like this to the moviefilein TOP ‘play’ parameter but I have no idea what I’m doing.

1 if op('switch1')[index]=2 else 0

Translation: play if the switch index value is 2, else don’t play.

I don’t know how to get the switch’s index value into my little script.

I’ve looked at a few examples of similar things, but they all used python which is over my head.
I have a feeling you’re going to tel me I need to learn python.
I am nervous.

Thank you,
Kristen.

Hi @kristenbarrios,

the python you have here is pretty close to be theoretically correct: When accessing parameters, you would will have to reference them via the .par object that exists for every operator. So instead of what you have, a corrected python expression would be:

1 if op('switch1').par.index == 2 else 0

Python is generally useful knowledge in TouchDesigner and with increasing complexity of your projects, a good basic knowledge of python will make things a lot easier. Our curriculum at learn.derivative.ca has a very basic introduction to DATs and scripting which might be helpful:

That being said, understanding how to use CHOPs in these kind of situations, can get you to the same result without typing python expressions.

Whatever value you use to control the index, you could utilize a Fan CHOP to create index channels which in turn can be used to control the playback of your Movie File In TOPs. Check out the OP Snippets to see examples on how the Fan CHOP works.

cheers
Markus

Thanks heaps, Snaut!

Really appreciate your detailed reply.
I’m only up to 104 in the fundamentals series - sounds like I need to binge a few episodes and get to 107.

Fan CHOP is going to be pretty useful for distributing values, and OPSnippets is the best!

Thanks again.

1 Like