Description of the problem:
I am currently creating an online experiment from the builder (v2020.2.5) and have around 200 image stimuli which I will need to load. The specific image shown will depend on various trial parameters, so I would like to define my image name as a variable which is set in a preceeding code component (imdisp = resources/S${targs[ttarg]}_${curvs[tcurv]}_${oris[tori]}_${sides[tside]}_pre_distr_${bdistr}_${trep}.png;
and $imdisp as the variable in my image component, updated on every trial).
I have seen older discussions of similar problems but there the additional resources tab or creating the resources folder often seem to have worked in the end most of the time.
As the image files are never explicitly named they are not added to the resources automatically and I get a resource not found error when trying to run it both in the local debug and pavlovia pilot mode.
I have tried to create a specific resources folder in which they are stored (this was not done automatically) as well as adding them via the ‘additional resources’ tab in builder but without success so far. Adding files via the additional resources tab also does not seem to modify the resources section in the .js code.
My general folder structure is TempDimOnline(the basefolder for my online experiment without specific html folder)/resources. When the name of the image stimulus is defined it can both be within the resources folder or just in the basefolder as long as the path is set correctly.
Is there maybe some workaround for this I could try?
This example will download custom files based on the participant number.
Make sure there is time for the files to be downloaded before they need to be used.
Address the resources in the experiment without their file path.
$ does not mean “variable”. It tells a non-code component to interpret then following text as code. It therefore shouldn’t be used in code components and should only be used once in a given component field.
Hi Wakefield,
thanks a lot for your help! If I understand correctly this would however still only add single files, rather than the content of a whole folder to the resources, correct? As I would still need to load all images for every participant I would then have to first loop through all the possible values my conditions can take to compose all my image names as strings (or provide a list including all image names in some other way) and finally add all of those to the resources in a specific code component. I thought there might be a way to still make it work through the additional resources tab or changing the folder structure, but I will resort to that otherwise.
I understand what the $ generally indicates in the builder. In this case it is placed multiple times within my code component as an automatic JS translation to the python f notation allowing to compose strings and imdisp itself is generally defined correctly.
Yes, I believe that you have the choice of loading all relevant files individually in code_JS (build up the list and then send it once) or all files ahead of time.
The formatting you refer to didn’t used to work in JS auto translate. I don’t know if it works in 2021 versions.