I’m an absolute beginner with Touchdesigner and I’m not able to solve the following:
I have a Filein Dat that continuously reads the contents of an external textfile. As long as the content doesn’t change, nothing happens, but as soon as the content changes, I want to start a process in Touchdesigner every x seconds. How can I do that?
there are 2 possibilities here. The first one would be to hash the string into a number that hopefully is always different from the previous and use this number to cause a trigger. The idea is to append a Eval DAT to the FileIn DAT and use this expression in the Eval DAT’s “Expression” parameter to hash the number:
The result of this is a integer number - which can cause collisions as we are looping around the 8 digit length. Now use a DatTo CHOP to convert the text into a channel value. This can be fed into a Logic CHOP with the “Convert Input” parameter set to On When Value Changed. Now this can be used as an input to a Trigger CHOP or as a start pulse to a Timer CHOP or similar.
The second option would be to use a DAT Execute DAT with it’s “DAT” parameter referencing the FileIn DAT. THe DAT Execute contains a variety of callbacks which you now can use to execute python scripts when the content of the DAT changes. Here you could for example pulse the “Trigger Pulse” parameter of a Trigger CHOP: op('trigger1').par.triggerpulse.pulse() or start a Timer CHOP: op('timer1').par.start.pulse()