I am trying to get PsychoPy to play a video along with one randomly selected song from my conditions file, I want the loop to end after one iteration because otherwise it will repeat the video with each of the songs from my conditions file.
I have added:
‘myCount = 0’ to before experiment and then:
‘myCount = myCount + 1
if myCount > 1:
trials.finished = true’ to Begin Routine
However I am still getting the error message ‘UnboundLocalError: local variable ‘myCount’ referenced before assignment’.
Sorry I’ve just tested with more trials and have realised that it only works for the first trial, I have put the code into the following trials but after the first trial they all repeat the video with each song in my conditions file until each one has been played.
Do you know why the code isn’t working following the first trial?
Thanks again.
This only works if your loop is called trials. For example, you might want trials_2.finished = True
However, it’s good practice to reuse routines whenever possible. If the only difference between A, B & L is the spreadsheet then you should use A for all of them, in which case you would need currentLoop.finished = True