psychopy.org | Reference | Downloads | Github

continueRoutine = false on Pavlovia

URL of experiment: https://gitlab.pavlovia.org/piet/pe-pavlovia/blob/master/html/PE-online.js

Description of the problem:
I have two internal loops, trials_neg and trials_pos: if participants are assigned short_start == 1, I want to skip trials_pos the first time they encounter it; there is an outer loop, outerLoop, with nReps == 2. In Javascript for Pavlovia (I’m not familiar with javascript), I am stuck!

In Each Frame, I try the following with no result:

if (short_start == 1) {
    if (counter == 1) {
        outerLoop.finished = true
    }
    else if (counter > 4) {
        outerLoop.finished = true
    } else {
        continueRoutine = true
    }
}

if (short_start == 0) {
    if (counter > 3) {
        outerLoop.finished = true
    } else {
        continueRoutine = true
    }
}

Whether I use outerLoop.finished = true or currentLoop.finished = true doesn’t make a difference. I want to make it possible to skip trials_pos, and it doesn’t make a difference, whether this inner loop is skipped, or if the outer looped is restarted.

This works in the python part:

#counter
counter += 1
#if short_start group, we should exclude pos_trial on the first run
if short_start == 1:
    if counter == 1:
        break
    elif counter > 4:
        break
    else:
        pass
if short_start == 0:
    if counter > 3:
        break
    else:
        pass

In Begin Routine, I put

var short_start
var counter
counter++;

thinking that it will add 1 to the counter for each loop through trials_pos, and sometimes it says that short_start and counter are not defined, and I put them there, but it is probably wrong.

I know that there are other similar topics, but I simply cannot figure this one out.

Thank you!

if (short_start == 1) {
if (c == 3) {
continueRoutine = false
} else {
continueRoutine = true
}
}

in Each Frame and c++; in End Routine for the routine before (trials_neg) seemed to do the trick but not when c++; was in Start Routine of trials_pos