Question about exp.set function
For my experiment, I am trying to set up the basic response counterbalancing, such as the one in the lexical decision example experiment. I made the inline_script object at the very start of the experiment (see picture)

Then I put up a sketchpad called Instructions, with the following text:
If the face is HAPPY, press [happy_response]
If the face is FEARFUL, press [fear_response]
However, when I attempt to run this, I get an error message, informing me that variable "happy_response" does not exist. The variable is present in the variable inspector, and its source listed as this inline_script (again, see picture), however in spite of my using exp.set function, OpenSesame does not assign the value to the variable, nor does it recognise it when it's called in the sketchpad.
Any ideas? I tried different order of the commands, checked a hundred times that the spelling is identical all over, but nothing changes. I am new to the software, but I read the manual and I really can't tell that I did anything wrong.

Comments
Hi,
To understand the problem, you need to understand the prepare-run strategy that OpenSesame uses. Every item from a
sequenceis called twice: first to prepare, and then to run. In your case, you define your variables in the run phase of yourinline_script. Because thesketchpadis prepared during the prepare phase (which comes first) the variables don't exist yet. Does that make sense?So the solution is to move your code to the prepare tab of the
inline_script.See also:
Incidentally,
exp.set()is outdated. The modern way to interact with experimental variables is to use thevar.var_namesyntax. See:Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi,
thank you, that worked like a charm!
However, now I have a different problem, again with the inline script. I tried to create a script to tell the program which response is correct, which looks like this:
However, as you can see in the variable inspector, no matter what I do the accuracy is 0.
What did I mess up this time?
Hi,
There are a few things wrong here. The first has to do with Python syntax:
As they say, I don't think this means what you think it means. You can find some background information about using
andandorwithstrings here:But basically, if you want to make a random choice, you can do something like this:
Regarding setting
var.correct_response: The expected value is a semicolon-separated string, not a list. So you'll simply want to do:Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!