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

Okay, and what would happen to the builder code I have for each routine? That code is responsible for switching to the next animal after 10 clicks, for playing a sound when the animal is tapped, and for changing the image when the animal is tapped.

If I understand your design correctly then an outer loop can change the selected rows of the inner loop every 10 trials, and you routine should already play a sound and/or end the routine and/or change the image when the animal is tapped.

Okay, so I should be removing all builder code components and instead use loops to control all of this?

I don’t know what all of your code components do, but if you start with trying to get a single routine that will play all the stimuli from a single spreadsheet then an outer loop can be added to select rows 10 at a time

Okay, I will try this and get back to you. Thank you!

Hi again! I am having a bit of a hard time understanding exactly what to do. For the experiment, in routine 1 (titled animal1) when image_1L is clicked, sound_low1 needs to play for its duration of 4 seconds, and simultaneously popup_1L needs to appear over image_1L. popup_1L can disappear when the sound is done. The same thing goes for image_1R, with sound_med1 and popup_1R. Additionally, after clicking either image a total of 10 times, the routine should move to the next one (next animal stimuli). How specifically can I modify components in the routine and/or use loops as you suggested, rather than code? Thanks again I really appreciate it!

Hi again, I have tried making a simpler version of the experiment and uploading it to Pavlovia using no code. I am still getting the initialising error with the auto generated java script. Is there any way you can help me? Thanks!

What is the error message?

Screenshot 2025-04-02 at 5.56.04 PM
This is the message we are currently getting. I know it is in the code that is autogenerated but we do remove this, resynchronize with Pavlovia and then it proceeds to give us the same error as if we did not fix it in the first place.

Please could you add me (Wake) as a developer and I’ll take a look tomorrow.

I actually just fixed this error but have received another one. I will attach an image.

Where was the bracket error?

Do you have a polygon with fill colour $None? Try changing it to None.

I do not have a polygon, but I did manage to move past this error (I am not sure how). I created this experiment to ensure I was able to upload to Pavlovia once replacing code with loops and am now successful. I am still struggling with configuring the experiment now though. I need the images to be tapped a total of 10 times, but it only allows for one tap each. Then the sound will no longer play when tapped. I am not sure what I am doing wrong but I will attach the experiment file. Thank you in advance I appreciate all of your help.
trials1-16 (low on left)?.psyexp (25.5 KB)

Looking at the Builder file you’ve uploaded.

I don’t understand popup_1L/popup_1R. They have images set every frame but no each frame code to edit the value.

The condition “$mouse.isPressedIn(image_1L)” might not work onlie. In any event I think it will only play once.

Your Each Frame code doesn’t do much.

if (mouse.isPressedIn(image_1R) or mouse.isPressedIn(image_1L)):
    if not mouse.clicked_this_frame:  # Ensure it's only counted once per frame
        click_count += 1  # Increment the click count
        mouse.clicked_this_frame = True  # Mark that a click happened this frame
        print(f"Click registered: {click_count}")  # Debugging line
# Reset flag when no mouse press is detected
if not mouse.isPressedIn(image_1R) and not mouse.isPressedIn(image_1L):
    mouse.clicked_this_frame = False  # Allow a click to be counted again in the next frame

print(f"Current click count: {click_count}")  # Debugging line

could be reduced to

if mouse.isPressedIn(image_1R):
     if not mouseClicked:
        click_count += 1  # Increment the click count
        mouseClicked = True
        if click_count > 1:
              sound_med1.play()
        if click_count == 10:
              continueRoutine = False
elif mouse.isPressedIn(image_1L):
     if not mouseClicked:
        click_count += 1  # Increment the click count
        mouseClicked = True
        if click_count > 1:
              sound_low1.play()
        if click_count == 10:
              continueRoutine = False
else:
    mouseClicked = False

Put mouseClicked = False and click_count = 0 in Begin Routine

Print statements every frame will overload the system.

Should I set the pop up images to every repeat instead? I will definitely change the code to what you suggested. I am just struggling with how to allow my two images to be clicked 10 times and when clicked the popup shows up with a sound playing. Right now I can only get them to be pressed once each. Is there something I can do to fix this?

It would be easier for you to code if you have a trial routine which ends on a valid click and then a feedback routine which duplicates the display and plays the sound. Then loop around the pair with 10 repetitions.

Hi, I also have the same issue, an Illegal return statement error in the JavaScript console when running my experiment online via Pavlovia. It seems to be related to the handling of the Escape key, which is auto-generated by PsychoPy. Interestingly, the error only occurs in one specific routine, where I use both an inner and an outer loop to repeat incorrect trials until they’re answered correctly.
I suspect there might be something about the structure of that routine that’s causing a mismatch in the function block.Would it be possible to share the Builder file or the exported JavaScript code here so you could take a look? I’d really appreciate it!