| Reference | Downloads | Github

Conditional branching


At the end of the instructions, I’d like to give the participants the chance to either see them again or continue with the task if they are ready. cont4.psyexp (65.7 KB)

Is there some template code that I could use for this?


Surround your instruction routines with a loop (not connected to a conditions file and nested within your main trial loop). Insert a code component on the last instruction routine and in the “end routine” tab of that window, enter something like this:

if 'n' in your_keyboard_component_name.keys:
    your_loop_name.finished = True

Customise to suit your key press options and the names of your objects. ie in this case, if the person pushes n, then the loop finishes and the rest of the experiment proceeds. If any other key, then the instructions will repeat. Give the loop some number of repetitions that will exceed the likely number of repeats needed.

Thanks so much!