psychopy.org | Reference | Downloads | Github

JavaScript - continueRoutine = false -- problem online

URL of experiment: https://run.pavlovia.org/MJB/immanentjustice/html/

Description of the problem:

The experiment flow contains catch trials which only run on set trial numbers.
There is a piece of code that runs at the start of the routine, which determines whether a catch trial is to be run. If not, the command is continueRoutine = false.
There is a separate code component set to run on each frame of the catch trial routine which handles what is shown on the trial.
This works well locally, but online it appear that the continueRoutine command is ignored and a catch trial is set to occur after EACH trial. This throws an error message because the components to be displayed on a catch trial are then not defined (they are defined in the piece of code at the beginning of the routine, but only when the right trial number is true).

My sense is that continueRoutine = false does not work on JS.
But it could also be that the timing with ‘begin Routine’ and ‘Each Frame’ works differently in JS than locally.

Can you please advise?

THanks!

Marc

Hi @Marc_Buehner, yes there are differences in how continueRoutine works in PsychoPy and PsychoJS. The main difference here being that, in PsychoJS, continueRoutine is assigned a true value on every frame. So, if you set the continueRoutine value to false in the Begin Routine tab, this will be overwritten in the Each Frame section of the code. The fix is to set the continueRoutine value conditionally in your Each Frame tab of the code component.

Hello David – thank you for this.
I tried that, but now the catch trial is cancelled ALL the time, i.e. the code

if (nTrials in [1,2,4,5,6,7,9,10,11,13,14,15,16]) {
continueRoutine = false;
}

does not seem to work, and the routine is cancelled always, not just on the trials in the list.

url:
https://run.pavlovia.org/MJB/immanentjustice/html/

Many thanks
Marc

HI @dvbridges. Sorry to bother you – did you have any more thoughts on what could be going on with continueRoutine in the above case?
I also noticed that not only is the routine cancelled all the time, but that the experiment does not run the required N of trials – it displays an NaN when it should display text from a list.
This did not happen when the continueROutine = false code was in the BeginRoutine tab.
THanks
Marc

1 Like