I’m new to PsychoPy so I’m trying to figure out things that might sound very basic. I have an experiment that worked beautifully last week… When I try piloting it now, it’s stuck on “initialising the experiment”. This is the same experiment re-uploaded (successfully) with a new name. How do I trouble-shoot? I looked up previous responses to such problems and I don’t understand how to proceed (e.g., I don’t know how to “debug the JS script”).
Does your experiment have any code components? That is, in the builder, have you added any custom code? If so, are those components set to code type “auto->JS”? That’s where the document above comes in most handy, making sure that there’s nothing in your code components that won’t work in JS.
When it gets stuck on “initializing the experiment”, you can open your browser’s JavaScript console to see what error it is producing. In Chrome, you can find this by going to View -> Developer, and it is similar in most other browsers (just look up “JS console” for your browser and you will find instructions). If you can copy the error message it will give a better sense of where to look.
If you want more detailed help, you can link your experiment repository. For the experiment that isn’t working, on its Pavlovia page go to “view code” and post that link here. Make sure to make the repository public, which you can do on that page by going to settings -> general -> permissions.
When I run the experiment with the new name (as well as the experiment with the old name), the error is the following:
Uncaught SyntaxError: Identifier ‘xys’ has already been declared
I’ve just had a look at your JavaScript and your variable xys is being used to store the locations for several different items. I would recommend using a different variable name in each case (e.g. xys1, xys2, etc.)
It seems you have multiple “mouse” components in the C1 trial type, and that looks like the root of the error. I’ll make a note of this for the developers, but it looks like the way PsychoJS stores mouse data, it can’t handle there being more than one mouse component in a single trial. Can you redesign your experiment so there is only one mouse component?
ah, ok. I need to have participants click on one of three buttons in that routine. I’m sure there’s a way to do that with a single mouse click, but I don’t know how. I tried looking this up in existing demo experiments and I copied code from there that then I couldn’t debug. So I opted for three mouse components instead. This did work when I first piloted the experiment so I’m surprised it’s craashing now… In any case, how do I fix this to only have one mouse click?
Many thanks, that worked!
I have a different problem now, though. The experiment doesn’t load in all my pictures (error message: " unable to download resource: [picture name] Try to run the experiment again. If the error persists, contact the experiment designer"), so I’m going to try to resize the bigger ones. Another error message pops up when I close the window with the experiment but it stays on the screen for a tiny fraction of a second and disappears, so I have no idea what it said. Was something in PsychoPy updated/changed over the weekend…?