Nested Loops not working Pavlovia

I was wondering if anyone has got nested loops to work in Pavlovia? I’ve seen a few posts saying people have had difficulties, and I had the same thing (worked fine locally, but got a ‘Javascript error’ when working on Pavlovia).

It would be great to know if it’s possible :slight_smile:

Thanks in advance :slight_smile:

I use nested loops quite often.

Are you trying to use .thisN?

Thanks for your response! I apologise - the problem turned out to be something completely different which I’ve now fixed. (If this helps anyone, it was that I was using variables named ‘image’ and ‘sound’ which seems to work in the Python but not JS version).

I actually now have another problem with converting from Psychopy to JS. I’m trying to put in a stimulus which appears for a variable duration. To do this, I’m defining a variable at the beginning for the duration called ‘intertrialint’, and will ultimately want to set this to a changing value each repeat of the routine.
However, while I can pass the ‘intertrialint’ variable into the ‘duration’ part of the stimulus in Psychopy (Python), when I try to run this online (with JS) it says ’ ReferenceError: asarray is not defined’.
Having looked at the JS version of the script, this seems to be because in the Python version it has a line saying ‘from numpy import … asarray’
whereas in the JS version it just skips to asarray being used, in the line:

frameRemains = 1.0 + asarray(intertrialint) - psychoJS.window.monitorFramePeriod * 0.75; // most of one frame period left

Do you know why this is, why the possibility of changing this variable is not passing to Javascript?

My experiment is: SequenceTask1 [PsychoPy]

Thanks so much :slight_smile:

I’ll add image to my crib sheet list

Variable names to avoid are: core, index, Object, Length, Number, round, sound, Symbol, t, thisTrial, trials, util, visual.


About the asarray problem. In another thread I’ve got a little pointer that might help? Error message: asarray not defined - #3 by thomas_pronk

1 Like