Writing contains(mouse) to output

Hi, you’ve come up with a nice way of getting around the issue of the double click.

You can simply add custom data fields to your data file using thisExp.addData(). Can’t resist also suggesting a more concise way of doing the whole thing though:

# this list should could just be created once per trial, in the 'begin routine' tab:
stimuli = [topLeftImg, topRightImg, bottomRightImg, bottomLeftImg]

# and this run on every frame:
for stimulus in stimuli:
    if stimulus.contains(mouse) and stimulus.name == corrAns:
        thisExp.addData('clicked_stimulus', stimulus.name)
        continueRoutine = False
        break # end the loop on first click

Using loops like this allows you to avoid repeating code, which easily allows errors to creep in. e.g. notice how in your code above, you actually test topLeftImg twice? A key mantra in programming is DRY: don’t repeat yourself, because such code is error-prone and hard to maintain.

Also note that you don’t need to set continueRoutine = True, as it will remain that way unless set otherwise.