To use a timer for the 20-second delay, you can utilize the Timer CHOP in TouchDesigner. Here’s how you can set it up:
-
Setup OSC In CHOP: Ensure you have an OSC In CHOP receiving messages.
-
Add a CHOP Execute DAT:
- Create a
CHOP Execute DAT and connect it to your OSC In CHOP.
- Configure the
CHOP Execute DAT to trigger when a new OSC message is received.
-
Add a Timer CHOP:
- Create a
Timer CHOP.
- Set the Timer Length to 20 seconds.
-
Script to Control Cooking State:
- Edit the
CHOP Execute DAT to start the timer and control the cooking state based on the timer.
Here’s the script to put in the CHOP Execute DAT:
# This function is called whenever the specified condition is met
def onValueChange(channel, sampleIndex, val, prev):
# Start the timer when a new OSC message is received
op('timer1').par.start.pulse()
# Change 'base1' to cooking state
op('base1').allowCooking = True
- Add a CHOP Execute DAT for the Timer:
- Create another
CHOP Execute DAT and connect it to the Timer CHOP.
- Configure this
CHOP Execute DAT to trigger when the timer completes.
Here’s the script to put in the CHOP Execute DAT connected to the Timer CHOP:
# This function is called when the timer is done
def onDone(channel, sampleIndex, val, prev):
# Change 'base1' to not cooking state
op('base1').allowCooking = False
- Configure Timer CHOP:
- In the
Timer CHOP parameters, set the Timer Length to 20 seconds.
- Ensure the
Done output is enabled.
With this setup, when a new OSC message is received, it will start the timer and set base1 to cooking. After 20 seconds, the timer will complete, and base1 will be set back to not cooking.