| Reference | Downloads | Github

Copied a routine with code component, no longer works

OS Win10
PsychoPy version v3.2.4
**Standard Standalone? yes
What are you trying to achieve?:

I created a reading task with a routine containing a code component that instructs to have a break after given trials. This works fine. I created a second routine with a second batch of stimuli (I need some stimuli from the two routines to be further apart so I had to separate them) and literally copied each component from the first routine. This time the break doesn’t appear. I tried changing the trial numbers in the code component, so instead of

if not trials.thisN in [1,3]:
    continueRoutine = False

it now says

if not trials.thisN in [7,9]:
    continueRoutine = False

but that didn’t work either (I only have 6 stimuli in each routine for the moment, it’s temporary).

The rest of the routine works except for the break.
Any ideas why ? Does the problem come from the trial numbers ? If so, can I rather say “have the break routine every 2 trials” for instance, like with a percentage ? I saw some post using
if your_trial_number % 2 == 0
but that created an error (“your_trial_number not defined”).

Thanks a lot, again.

We really need to see a screenshot of your flow panel.

Please explain what you mean by that: we can’t offer suggestions unless we know what is wrong. But we also need to know exactly what you do want to happen.

There is an art to asking questions in forums like this: you need to review each post and ask yourself “could someone give an answer to this question, knowing nothing other than what I wrote here?


Someone posted that code assuming that the reader would replace the placeholder text your_trial_number with an actual name that was of relevance to their specific code.

Hello Michael and thank you for responding. Sorry I wasn’t clear.
I actually found where my mistake was : I did not change the code from
if not trials.thisN in [1,3]:
if not trials_2.thisN in [1,3]:

The name of the loop was wrong so it didn’t pick up on the right trial numbers.
I still attach a screenshot in case this might be of help for other people.

Thanks again.