One background music during a loop

OK, that is quite a heroic approach! As you’ve seen, Builder-generated scripts are quite verbose and it can be hard to get it right when trying to customise them. Using a graphical code component has (at least) two advantages:

  • You just select which tab to put the code into, and Builder will automatically insert it in the correct place in the script, without breaking anything.
  • You can continue working within the graphical Builder interface. Manually customising the .py file is a one way street: you have to keep working with that script from then on, and can’t tweak it by working on the .psyexp file via the Builder GUI,

So I’d recommend that you discard this edited script and go back to the Builder GUI, insert a code component from the “custom” section of the components panel, and put the code in the tabs as suggested above. This will just take 1-2 minutes and then you’ll still have a graphical Builder .psyexp file that you can continue to develop.

This isn’t just a suggestion for new users: we would recommend this approach in almost all cases, even for people quite comfortable with Python programming.