Hi,
PsychoPy will interpret any values in condition files as literal values - e.g. the literal letter 'A'
, rather than the stimulus object called A
. So you need to tell Python to interpret the variable as containing the name of an object, rather than as literal content. Fortunately Python is a dynamic language and allows you to do this via its eval()
function. So in the “clickable stimuli” field, try putting this instead:
eval(Target)
Otherwise, I think you’re on track.
EDIT: I just saw the second part of your question… This will be a bit trickier. Instead, I think you will need to just list all clickable stimuli (i.e. A, B, C, D, E
) in the clickable stimuli field.
Then you will need to have some custom code to check if the correct one has been clicked, and then end the routine. i.e. insert a code component (from the “custom” component panel).
In the “each frame” tab, put something like this:
if eval(Target) in mouse2.clicked_name:
continueRoutine = False
Change “End routine on press” to be “Never”, since you are handling that yourself now in code, and don’t want the mouse component to end the routine automatically.
The variable mouse2.clicked_name
in your data file should contain a list of clicked stimuli. On a correct trial, it will only contain the name specified in the Target
variable. On others, it will include one or more other names, as well as the correct one.