If this template helps then use it. If not then just delete and start from scratch.
OS: Win10):
PsychoPy version: 2020.2.2
What are you trying to achieve?:
I am attempting to create a conditional routine within a loop which is initiated by the mouse component. The task is Sentence Repetition where the participants can rehear the sound by pressing the back button, or go on to the next trial after they’ve repeated the sentence.
What did you try to make it work?:
I followed this tutorial on branching: https://www.youtube.com/watch?v=kwbHGnJPEHM&t=337s which was really helpful but doesn’t seem to work with the mouse component (unless I’m doing it completely wrong!). I’ve followed all of the instructions here, but changed this code in ‘End Routine’ based on key responses:
if(key.oldnew.keys == ‘c’):
dork = 1
else:
dork = 0
(where if you press ‘c’, it employs the loop with nReps$ = ‘dork’ and if you press any other key, it proceeds to the next trial)
to:
if(click_trial == repeat_icon_trial):
repeatsound = 1
else:
repeatsound = 0
(where if you click the polygon called ‘repeat)icon_trial’ with the mouse component named ‘click_trial’, the loop with nReps$ = ‘repeatsound’ is employed)
What specifically went wrong when you tried that?:
The loop/code does allow me to click either the back button or the next button BUT, regardless of which one is pressed, goes onto the next trial (i.e. the loop simply isn’t working and not even throwing up a error message).
I’m a newbie to using code so any help is greatly appreciated!
Essentially a message is presented (for you this would be a spoken message) and the participants clicks to either hear it again or move onto the next message. It is a little different to your original demo, but should work pretty similarly.
Thank you so much for your reply, this is exactly what I want to do!
Unfortunately, although the conditionalMouse task runs wonderfully and I can play around with the code (changing names etc) and it still works, the code doesn’t seem to work within my experiment and throws out the error message:
AttributeError: ‘Mouse’ object has no attribute ‘clicked_name’
I’m wondering if this is because my clickable options are images, not text…? Or is this completely unrelated and I’m missing something huge…?
It should still work fine with image files. In order to have the attribute ‘clicked_name’ though it is important to make sure the mouse ends on ‘valid clicks’ and that the image component names are listed as ‘clickable stimuli’ - please can you confirm the mouse parameters are identical?