| Reference | Downloads | Github

Variable Position Causes Object to Disappear Online

URL of experiment:

Description of the problem:

Program runs fine locally, but when push to Pavlovia, text stim with a variable location do not appear. But when position is set to constant values they appear. (Have had this issue on multiple experiments I’ve been building).

psycho.JS script for the variable position appears to be fine.

// update component parameters for each repeat
ABE_Box.setLineColor(new util.Color(Box_Colour));
T1_Target.setPos([T1_Target_Pos_1, T1_Target_Pos_2]);
T1_Dist.setColor(new util.Color(T1_Dist_Colour));
T1_Dist.setPos([T1_Dist_Pos_1, T1_Dist_Pos_2]);

Any help would be greatly appreciated!

@lorentlm, this looks like a scoping error, where the use of var declarations in the code component has limited the scope of your position variables to the beginning of your Select_Trial routine. Remove the variable declaration var from your variables in the code component, unless you explicitly want the variable to have local scope. E.g.:

// This line needs the var removing
// var T1_Target_Pos_1 = td_pos.parseListIndex(td_pos.createRandomIndex());

// Correct
T1_Target_Pos_1 = td_pos.parseListIndex(td_pos.createRandomIndex());

Thank you for your suggestion! But unfortunately that did not solve the issue.

I should also mention that the issue seems to only occur for text stimuli, not shapes or images.

Ok, would you mind posting a working pilot URL for the task ?

Thank you!

@lorentlm, apologies, the pilot token has expired. Can you explain with a bit more detail what the error is? Is it that the white word is not appearing? If so, there does not appear to be a call to set the position of the T2 text (the white word?) on each repeat, and as a result it may be drawn under shape stim that is also presented. Set the position of the T2 text to update on each repeat, and also position it lower than the shape stim in the Builder routine, if possible.

The T2 stimulus position doesn’t change, which is why it doesn’t appear in the code, as you mention. As well, T2 does appear when I run online—presumably because the position is constant.

Its the T1_Target and T1_Dist objects that have the changing positions and do not appear when I run online, only when I run locally. However, these item do appear when I run online if I set the position to be constant and use my desired values. It’s when I put those desired values in as variables that the images do not appear online. (These objects appear below the shape stim in the code, so that shouldn’t be an issue for these stimuli). This problem happens whether I set the variable using custom JS code, as done in the experiment I posted about here, but also when I load them in from an excel file in another experiment (not pictured here).

However, I don’t have the same problem with shape or image files. I’ve looked at the psycho.JS code and the same function is used, .setPos(), for all of these object types—so I’m not sure why it is just text stimuli. I also found another user who run into the same problem (text stimuli don’t appear online when use variable positions) 11 days ago.

I will have to take a look later, apologies.

I was able to fix the problem—a silly error on my part. I had left a “$” in the GUI for stimulus position. Removing it made the images appear again.

Thank you for your help!

1 Like

Hi @lorentlm, could you explain a bit more on how you solved the problem? I thought you do need the “$” size in the GUI when the parameter value is set to a variable? (like this)

I had a similar problem with image components. When the image name is a variable (like in the screenshot above, lastFrame is a string defined in a code component). This presents the desired image when I run the experiment locally, but when pushed to Pavlovia, the image doesn’t appear (and there is no error message). Any idea how to fix this? Many thanks!

If you just remove the “$” from the Position parameter box it should run correctly both locally and online.

I’m not sure, but I think it has to do with the name of the position parameter box—Position [x,y] “". I think the "” is included in the name because it’s not needed when you specify the parameter. Someone please correct me if I’m wrong!

But regardless, just removing the “$” should fix your problem!

**for some reason the $ in my replies aren’t showing. Anywhere you see “” should be read as a dollar sign.

Thanks! It seems that the experiment runs fine if I remove the “$” in Position, but not for the image name. If I put “lastFrame” instead of “$lastFrame” in Image, it returns this error message:

14.9966 ERROR Couldn’t find image lastFrame; check path?

On the $ – it says Image with no $ but Position [x,y] $ which indicates that you don’t need to add a $ for position.

1 Like