Hello!
I am developing an experiment into Builder and using some Code components to handle calculations, feedback, loops, etc. It has a complex workflow and I would like to make my routines as reusable as possible. I am also using a datasheet with thousands of stimuli and picking just a random subset of them.
That said, I would like to retrieve the current loop to stop it after i.e. 30 repeats. For each single loop I have achieved that with this code:
namu_t_counter += 1
if namu_t_counter >= 30:
namu_loop.finished = True
However, I would have to duplicate the routine where this code is located at least 9 times (making it 10 almost identical routines) if I just copy them and adapt. So I would like to make a code to dynamically retrieve the current trial loop and handle it individually with the same code, so I can just insert the same routine several times in the Flow.
I’d appreciate any ideas on how to do that code (in both Python and JS) or what to look for, like hints on internal variables accessible through code, docs describing it (I have goodled, but found nothing so far with my keywords), etc.
Some information from the topic template that I think might help:
OS: Win10
PsychoPy version: 2020.2.10