| Reference | Downloads | Github

Stop routine based on exact time (not on click after defined period has ended)

OS: Win 8
PsychoPy version: 3.2.4
Standard Standalone? (y)
What are you trying to achieve?:

Im building a slider task, where participants are supposed to click in the middle (value = 50) of the slider. The slider stays in the same position on the screen until the middle is hit and then changes position. Participants have 10 seconds to click on the slider until an error message appears. One round should stop exactly after 30 seconds, no matter if the participant just clicked on the slider (50 or other value) or if the participant is waiting in front of the screen.

Thats the basic logic of my Experiment:

At the moment my code looks as follows:


*Begin Routine *
if trial_block.thisN == 0:
    startTime = globalClock.getTime()

*End Routine*
timeElapsed = globalClock.getTime() - startTime
if timeElapsed >= 30:
    continueRoutine = False


*Each Frame*
timeElapsed = globalClock.getTime() - startTime
if timeElapsed >= 30:
    continueRoutine = False
elif result == 50:
    trial_loop_2.finished = True
    trial_block.finished = False

Unfortunately with this code particpiants are still able to do one last click even if the 30 seconds are over, meaning that depending on the participant the round stops after 30 seconds (if he does a click in that exact moment) or after up to 39.99 seconds, if the participant doesnt click and waits for the 10 seconds allowed per slider to pass.

So now my question: How can I stop the round depending only on the time of 30 seconds and not having to wait until the participant clicks?

Thank you in advance for any ideas.