Thanks for getting back to me- I don’t have a record of the error messages but think they meant psychopy didn’t recognise the term trials.data (tried putting the code in all different boxes of the code component).
However- I found a really useful post on here that has helped me find another way to do this:
This helped me count the accuracy during each block (loop) and display this on the screen using a text component.
This was just the 1st step towards another aim: trying to create a stop /discontinuation rule to terminate the experiment once a participant had made a certain number of errors within a block (loop).
This is a pretty clunky way to do this (e.g., I’m sure there are more delicate ways to terminate the experiment!!), but just for info, in case anyone else ever wants to do this! My final code was- for each loop:
Add code component then for these sections add:
Begin Experiment:
errorsset=0
totalaccuracy=0
End Routine:
if key_resp.corr:
totalaccuracy=totalaccuracy+1
else:
errorsset=errorsset+1
thisExp.addData('errorsset', errorsset)
thisExp.addData('totalaccuracy', totalaccuracy)
if errorsset > 8:
endExpNow=1