Coding works for all routines but the first

URL of experiment: Pavlovia

Description of the problem:
I’m experiencing an odd event: the coding in the task works well for all routines but the first. I can’t figure out why this is happening because it works perfectly when running from my PC.

Nothing happens when I click on an image on the top of the screen in the first ‘test2’ routine:

But is works from the second routine on:

Am I doing something wrong or could this be a bug on the server?


Hi Mario,

I took a look and was as puzzled as you are. I think the issue has to do with setting the image of Colours on every frame, and changing your code such that you can workaround this, will likely solve the problem. You could do so, for instance, by changing the Colours image not via a variable, but via the function setImage.

Best, Thomas

Hi @thomas_pronk,
Thank you very much for checking my experiment!

Do you have a suggestion how to change the variables using the setImage function?
I’m a beginner in coding, so if you could give me an example to follow would be great.

Thanks again,

That would a nice demo indeed! Let me do a bit of coding…

I asked for some help of my colleagues to build something that meets the most modern standard, but that could take a while. I got a workaround, but that’s a bit contrived. Hang on! Or if you’re in a hurry, give a shout for the more complicated solution :slight_smile:

I can wait. Thanks a lot @thomas_pronk!!

1 Like

Hi, I had a similar issue with my experiment too. I tried to get an image component to go through a series of image files to create a movie-like stimulus, but it did not work at all on the first trial but works without any problem on later trials. I solved it by for the chunk of code in the JS file that initialized that component. It turned out the file path I assigned wasn’t taken, it showed “undefined” instead. I looked at the JS code from your experiment and found a similar piece of code (see screenshot). Maybe you could try manually edit the undefined image path to direct to your image file.


Hi @Beau_Zhang,

thanks for helping me! I tried to specify the image on the JS file but it did not work (probably because the image is set using the code component).
However, I inserted a “dumb” trial as the first, so now the experiment is working!! It is not perfect, but I think I can use it this way.

Thanks again,

1 Like