Branching in Pavlovia


I’m currently working on a study where I would like the participant to be taken to different screens depending on responses they have given using the mouse component.

In really simple terms, in Routine1 if the participant presses PolygonA they will go straight to the next trial, while if they press PolygonB they will be shown an additional screen, Routine2, before continuing on to the next trial.

To do this, I have inserted a code component at the top of Routine2, and in the ‘Begin Routine’ tab, I’ve written:
if routine1_mouse.clicked_name[0] ==‘PolygonA’:
continueRoutine = False

(where the mouse component is named ‘routine1_mouse’)

This works perfectly fine when run locally, but, when uploaded to Pavlovia, pressing either button (PolygonA or PolygonB) takes me to Routine2.

How do I ensure only a PolygonB click takes me to Routine2?

I’m really sorry as I’m sure this is a really simple question but any help would be really appreciated!


Try putting the code in Each Frame to end the routine you don’t want


This has fixed the problem PolygonA -> next trial and PolygonB -> Routine 2 so thank you! However, it’s created a strange problem with the sound.

In Routine2 (that participants should only be exposed to if they press PolygonB) there is a sound that should be played. When inserting the code in ‘Each Frame’ instead of ‘Begin Routine,’ I can press PolygonA and it takes me to the visual for the next trial (which is what I want) but is still plays the sound that they only should hear if they press PolygonB.

Does this make sense? If so, any ideas what may be causing this?