psychopy.org | Reference | Downloads | Github

Ending a Loop based on time and not number of iterations

So, I have designed an experiment where participants are allowed to type as many associated words in a set number of time. The routine and loop work flawlessly for a set number of iterations (lets say 10 responses or something). I can set the number of iterations to 9999 and just have an experimenter time the participant, but I would really like to automate this in PsychoPy.

I have tried reviewing other topics and solutions here on the forums. One solution I’ve tried is adding this snippet of code to each frame tab:

if globalClock >= 60.0:
continueRoutine = False
FreeRecallLoop.finished = True

However, when I add that to each frame, my experiment breaks instantly.

I believe I might not be placing it in the correct part of the code. I’ve been placing it in the “while continueRoutine:” section for this loop.

Any help is greatly appreciated!

Did you add indentation to that code snippet in the actual code component? If you encase code in triple backticks (```) on Discourse it will retain indentation, but people often don’t realise this and so if you copied it over it may have lost indentation.