Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Defining an element's location in sketchpad, using an equation?

Hey everyone,

I am trying to define the location of an element in sketchpad, using an equation, and I keep getting an error:

x should be int or float, not some_variable+5

The code:

draw image center=1 file="some_pic.jpg" scale=1 show_if=always x="some_variable+5" y=-401 z_index=0

The reason seems to be that OpenSesame adds "" to the code, after my edit (I entered: x=4+5, without "").

Does anyone has an idea how to make this work?


  • Hi,

    There is a way to make it work the way it is supposed to work (similar to your approach), but I don't remember what exactly it was. An alternative to bypass the problem is to precompute the value and only then change the coordinates.

    See the attached example. Does that help?


  • Thank you!

    It works.

    I would prefer to find a solution without an inline script, since some of my lab members are unfamiliar with programing.

  • I see what you mean, but does it really matter? One way or another you would have to code something that other users shouldn't change. No?

  • Usually you are right, but in this case the objective is to incorporate a script in all the experiments in our lab, and have the lab members be able to call its result without having to code.

    It's a calibration script for stereoscopic display of stimuli on VR headsets - the script manipulates some user input, and its results should be added to the location of every visual element in those experiments.

  • Sorry, but I fail to see why this makes the sketchpad solution better than the inline script. If lab members will not need to change anything, they won't do so either way. If they have change things, they also have to do so either way. In fact, I'd personally say the inline syntax is more understandable than whatever the code would be in a sketchpad.

    They only real disadvantage that I see using the inline_script is that you have to use another item, so that you have to be aware of the structure of an experiment and how the items in it interact to make it right.

Sign In or Register to comment.