Pavlovia - timer to terminate loop

Hi all. I have a timer coded in Python to terminate a loop after a certain amount of time passing. This is for a recall task, so importantly, it needs to terminate if there is no input. However, I am unable to replicate in PsychoJS to run on Pavlovia.

For example, in “Each Frame”

elapsedTime = globalClock.getTime() - startRecallTime
if elapsedTime >= recallDuration:
        Recall_Loop.finished = True
        continueRoutine = False

Wondering if anyone has a solution. I’m using PsychoPy v2020.1.3 but this isn’t a Python issue.

How did you code globalClock? If you used python then it does not work as Java does not recognise the package. You must use “globalClock = new util.Clock();” and then all the functions you normally use in python will work, such as .reset(); .getTime(), etc.

Thanks for this. I used your suggestion for globalClock.

The other modification was to define startRecallTime to the start the clock to run in a new routine (code only) prior the Recall_Loop.

I am having the same problem, but these solutions haven’t worked for me. This code works in PsychoPy but not in Pavlovia:
Timer Routine before beginning of Loop, code snippet in Begin Routine
timer = core.Clock()
timer.reset(newT=0.0)
In the last routine in the loop, code snippet in Each Frame
t=timer.getTime()
if t > 30:
delay_loop.finished=True
continueRoutine=False

I tried changing the first code to:
globalClock = new util.Clock()
globalClock.reset(newT=0.0)

and the second to:
t=globalClock.getTime()
if t > 30:
delay_loop.finished=True
continueRoutine=False

But this still didn’t work. Any suggestions?