OS (Win10): **
PsychoPy version (v2021.1.2): **
Standard Standalone? (yes)
What are you trying to achieve?:
I have two types of texts in a variable connected to my conditions file. Either one is randomly presented in each trial iteration followed by a keybord component. In trials where text 1 is presented I want the allowed keys to be different (e.g., 1, 2, 3) from the allowed keys when text 2 is presented (e.g., a,b,c).
What did you try to make it work?:
I have tried to give the name of a variable in the allowed keys field (e.g., posKeys, or just posKeys without ). I have tried to have the variable located in my conditions file like tis:
posKeys
[‘1’,‘2’,‘3’]
[‘a’,‘b’,‘c’]
I have also tried to define a variable in a code component in the beginning of the routine and then change it with an IF statement depending on if the trial is presenting text 1 or text 2, like this:
if (task_text == 1):
posKeys = [‘1’,‘2’,‘3’]
elif (task_text == 2):
posKeys = [‘a’,‘b’,‘c’]
What specifically went wrong when you tried that?:
When I give any variable name the program won’t run and I get this error message:
Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\keyboard_init_.py”, line 238, in writeFrameCode
keyList = eval(allowedKeys)
File “”, line 1, in
NameError: name ‘posKeys’ is not defined
I have seen that others have had similar problems, but I have not been able to find a solutions.