URL of experiment: https://run.pavlovia.org/jiang166/visual-attention-and-memory/html/?__pilotToken=e4da3b7fbbce2345d7772b0674a318d5&__oauthToken=22c7a4f7e2a08fe975b04f1053a2ea0a3f557a46c606fa00cb20cb70b6feb30b
Description of the problem:
I have a color working memory experiment that works just fine on PsychoPy. To code it up, I have an initExperiment routine at the beginning, in which I added codes to specify conditions. For those codes to work, I had to insert import a few things under “Begin Experiment”:
import numpy as np
These are necessary for my condition set up that involves a lot of array manipulations. Although the script runs well in PsychoPy, it does not run on Pavlovia. Instead, it gets stuck on initiating experiment…
In the HTML console, the error message says
SyntaxError: import declarations may only appear at top level of a module
The lines that cause the SyntaxError are those import lines. If I eliminate them, PsychoPy simply would not run. It seems that those lines need to go to the beginning of the experiment, but I if I manually edit this, I lose the Builder’s JS conversion function.
Any advice on how to create codes (import) that run in PsychoPy but don’t break Pavlovia?