Description of the problem:
Hello!
I recently created a simple temporal discounting task experiment on PsychoPy in which I have 160 trials total (2 reps of 80 trials) and I want to give the participants a break after every 40 trials.
I inserted this code component into the “Begin Routine” section of the “break2” routine, and this works just fine when I run it locally on my computer in Psychopy:
However, in Pavlovia when I run the experiment it shows the break screen after EVERY trial instead of just the specified trials that I want it to. I am assuming this has something to do with the way that Pavlovia/JS keeps track of the trial number that is somehow different from the way it is done in Psychopy, but as I am a coding newbie I am not sure how to fix this issue.
If anyone has any tips or tricks that would be greatly appreciated, thank you so much!
Hi Becca,
Thanks so much for your reply! I tried both things, I moved the code to “every frame” and changed it to both and then hit the sync button again at the top of the builder view (I think that’s all I need to do to update it online, correct?) and while it works fine in PsychoPy it is still showing the break screen after every trial when I run it in Pavlovia.
If you have any other suggestions that would be greatly appreciated! Thanks again for your help
I wonder - when I update the experiment locally do I need to export the HTML files again AND hit the sync button? Because when I look at my Gitlab page it says that the .psyexp files were updated recently but it looks like the html files and the .js files are still the original ones… maybe that might help?
Thanks again
Looking back on this I suspect this is the use of .thisN - this code should actually now work if running in 2021.2 or later (because thisN now exists in PsychoJS) - alternatively use a trial counter to create breaks i.e.:
Add a code component, in the Begin Experiment tab write: