Stop or continue block of trials depending on a condition

Hi, I’m having some questions regarding the block/trial loops. I’ve read other posts but I didn’t have any luck.

I have a block of trials and I want this block to be repeated maximum 6 times. But if a condition is met during the block I do not want this block of trials to be repeated again, and continue to the next loop of trials.
If this condition is not met until the 6 loops are done, I want the task to stop completely, not even go though the rest loops.

To demonstrate (sorry for the 2 images, but they don’t fit all in one)


So the nReps of training_blocks is set to 6 but if a variable “x” takes the value “1” (which is checked on routine “training_conditions”) I want the program to continue on the next loop of blocks (“blocks”). But if x never gets the value 1 I want to experiment to stop completely.

Thanks your for your time!

OK, you need a code component in your ‘training conditions’ routine something like:

if x = 1:
    continueRoutine = Flase # ends the current routine
    training_blocks.finished = True #breaks the trials loop
   endTask = 0
else:
    continueRoutine = Flase # ends the current routine
    training_blocks.finished = True #breaks the trials loop
    endTask = 1

then in all subsequent routines add a code component and in the ‘each frame’ tab (begin routine would also work locally but not online) add:

if endTask:
    continueRoutine = False
    name_of_current_loop.finished = True

Hope that helps,
Becca

Thanks! That helped indeed!