I am attempting to create a loop that ends after 16 seconds from the onset of the loop. This runs fine in PsychoPy, but for some reason the loop will continue for longer than 16 seconds on Pavlovia. Here is a screenshot of the relevant experiment flow:
I have tried making multiple small changes to this (such as removing the else statement) with no luck.
I also want to note that this task has been placed at the beginning of my task temporarily just so I can easily see the changes I make when piloting, but will actually be placed in the centre of my experiment flow. It is important that the timer does not start at the beginning of the experiment but at the point in which the word scramble task begins.
Thank you for your suggestion unfortunately I am still getting the same error, but I think I understand the logic behind what you are saying. Here is my updated code:
Hi all, I think this is a server issue since any new experiments have problems with piloting or running. This includes both experiments from new repositories and forked experiments from experiments that are known to work. It only seems to affect new ones, as old experiments seem to run fine.
I’ve changed both instances of new util.Clock() to Date.now(), which does exist the loop but consistently too early. Once the program gets to the routine that contains that code component with Each Frame, it quits.
I’m quite confused why this is happening, because the logic makes sense to me and I’ve followed directions from similar discourse posts.
I am having a similar problem today. My timer is being updated correctly, but continueRoutine is always true, despite my continueRoutine = false statement being included in the “every frame” part of the code component
Thank you everyone for your suggestions! I realized through this post that I needed to change “startTime” to “startTime.getTime()” in the “Every Frame” tab.
Hi there, I’ve been trying to get a time limit working on pavlovia for quite awhile and have not been successful.
Psychopy 2020.2.2, windows10, firefox
I am attempting to start a timer on the first routine, and then terminate the loop after a specified number of seconds have passed by checking the timer. The set-up I have in builder works correctly, but not so much on pavlovia.
I tried various version of these attempts(
“mainSARTBlock” is my trial loop):
A more “direct” translation of py to js (eg. using globalClock & maxTime) & just change the syntax to JS, but the code seemed to be completely ignored (i.e., no errors, but trials continued after specified time limit).
The code below, but removing the “new util.Clock()” in Each Frame (and instead just check that timer. getTime() is >= 8 seconds). The code appears to be “ignored” as described above in #1.
The code below, but swapping out “mainSARTblock” with
a. “trials”
b. “currentLoop” (both as per this
For a, I get the error “ReferenceError: trials is not defined”
For b, I get the same “code is ignored” behavior described in #1 above.
The code below, but in eachFrame JS I swapped out “(((new util.Clock() - timer.getTime()) >= 8))” for both “((mainSARTBlock.thisTrialN === 2))”, “((currentLoop.thisTrialN === 2))”, “((currentLoop.thisRepN === 2))” & “((mainSARTBlock.thisRepN === 2))” to check if the issue is how trials end in JS for psychopy version 2020.2.2 , or if the issue is my time component. Same behavior of code being “ignored” (where I am looking for the loop to terminate after 2 trials to pass that are within the first iteration of the loop), which makes me think the issue is at least with the way I’m trying to force end a trial? Given this I thought it’d work. To no avail
The code below, which has the same behavior of being “ignored” as described in #1 above.
I initially had errors where “timer” wasn’t being defined when I instead used .thisN instead of .thisTrialN, which I’m no longer getting, so I’m guessing the issue is in the EachFrame tab?
In Begin Routine:
Py:
if mainSARTBlock.thisN == 0: # only on the first trial
startTime = globalClock.getTime()
maxTime = 8
JS:
if ((mainSARTBlock.thisTrialN === 0)) {
timer = new util.Clock();
}
maxTime = 8;