PsychoPy task will not run when synced to Pavlovia (stuck at initialising)

Hello hope all is well! I have synced my PsychoPy experiment to Pavlovia, but when I try to pilot the experiment, I get stuck at initialising. I have figured out how to determine where the problem is, and have found the problematic line of code (illegal return error). It is not a builder coding error its in the javascript that is generated. I am not sure where to fix this, or how to fix this. Thank you for your help in advance!

What is the error message?

If it’s “illegal return” then there’s probably a stray bracket in your custom code.

Do you have any Both / JS code components which might have unbalanced brackets?

Thanks so much for the quick reply. The error message does say “illegal return statement” and gives the line of code that is an issue (3087, the one in the photo in the original post), and it doesn’t look like the brackets are imbalanced (we had checked this too)…could it be somEwhere else that it’s imbalanced?

Yes, the imbalance is almost certainly in code that you have written where you haven’s use an Auto code compoenent.

I do have it on Auto->JS however this is not an error with the builder code I wrote, it is with the automatically generated JavaScript code (in the separate JavaScript file I believe). I’m not sure how to find or fix the imbalance with this. Thanks for the help again!

Please could you upload your psyexp file?

Please find the psyexp file below. J
trials1-16 (low on left)?.psyexp (338.2 KB)

I’ve looked at one code component so far and I can see why it won’t work online.

What is event16?

Among other things, you are recreating your mouse component.

From the name of your experiment I also wonder if you have multiple near-identical Builder files running different variations of your task.

It used to just be event for every routine, but when trying to run it on Pavlovia it told me event could not be repeated in each routine (it got stuck on initialising and this was the problem), so I changed them all to have numbers at the end to make them different. It seemed to fix the issue because the next error was the original line of code issue I provided in the original post. And we do have near identical builder files running different variations.

Do you mean event as in the event module?

Please look at my Builder isn’t Coder tip and delete them all.

Okay I deleted all of the event codes in the builder code and it runs on my desktop! It still does not run on Pavlovia though and gets stuck on initialising. The error is still with line 3087 of the JavaScript code I attached the image of.

Are you looking at the latest version? The error can’t still be at line 3087.

Personally I would try to reduce the experiment to a single routine, with the outer spreadsheet containing the names of the inner spreadsheet (or row numbers) and the inner spreadsheet containing the animal details to customise the routine.

This is my latest version. There is still code being generated without my doing (separate JavaScript file) that I think is where the 3087 error is coming from? Would you be able to clarify how I can condense it all into one routine? Right now all 16 routines use different animal stimuli so I am not sure how it would all be able to run in one routine.

If you have a column in your spreadsheet called animalImage containing the full path of the image files then you can set your image component to show $animalImage

Ditto sounds and text.

I do not have a spreadsheet for the animal images, I just have spreadsheets to randomize the different routines.

But you could/should have…

Okay, sorry to ask but how would I go about doing this? I’m just super new to PsychoPy. Thanks again!

I’ve made this today’s tip. Hopefully this post will help.

Perfect, I will try this. Thank you!

If you start with making a single loop which shows all of you stimuli in a random order then you can add an outer loop which selects sets of stimuli you want in the same block (assuming that is your intended design).