What am I trying to achieve?:
I need to finish the routine when an interval point is reached (this interval is split into 1 second, 2s, 3s, 4s, and 5s).
I inserted a code component in a Routine where the video is displayed and with a resp component called ‘resp’:
In the code component I added:
myClock = core.Clock() currtime = myClock.getTime() exittime = 999
currtime = myClock.getTime() if currtime >= exittime: continueRoutine = False exittime = 999 if resp.keys == 'space': exittime = math.ceil(currtime) #to approximate the time
My idea is that Psychopy takes the time when the key is pressed (could be 0.67s, 0.88s, etc.), and finishes the trial when the time is 1 second (or if resp.rt = 3.55 → finish at 4s).
Right now, the Routine ends when the response is given (it doesn’t wait until the interval).
No error appears, it just doesn’t work properly!
Is there any error in my code?
Thank you in advance!