psychopy.org | Reference | Downloads | Github

Cannot read property 'map' of undefined

I continue to experience this problem and I don’t understand what it can depend on.

https://run.pavlovia.org/pierandrea/visualmatch_ver1/html

image

var _pj;
function _pj_snippets(container) {
function in_es6(left, right) {
if (((right instanceof Array) || ((typeof right) === “string”))) {
return (right.indexOf(left) > (- 1));
} else {
if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
return right.has(left);
} else {
return (left in right);
}
}
}
container[“in_es6”] = in_es6;
return container;
}
_pj = {};
_pj_snippets(_pj);
if ((_pj.in_es6(“z”, response) && (matchT === 1))) {
feedback_test.setText(“RISPOSTA CORRETTA!”, {“log”: false});
feedback_test.color = “green”;
} else {
if ((_pj.in_es6(“m”, response) && (matchT === 0))) {
feedback_test.setText(“RISPOSTA CORRETTA!”, {“log”: false});
feedback_test.color = “green”;
feedback_test.height = 0.05;
} else {
feedback_test.setText(“RISPOSTA SBAGLIATA!”, {“log”: false});
feedback_test.color = “red”;
feedback_test.height = 0.05;
}
}

What is the object your mouse is clicking on?

I think it needs to be either defined in a Builder component or in a Begin Experiment block

it’s actually the keyboard. But the code that was automatically generated is what you see.

this is the py code

if (‘z’ in response) and (matchT == 1):
feedback_test.setText(‘RISPOSTA CORRETTA!’, log=False);
feedback_test.color=‘green’
elif (‘m’ in response) and (matchT == 0) :
feedback_test.setText(‘RISPOSTA CORRETTA!’, log=False);
feedback_test.color=‘green’
feedback_test.height=0.05
else:
feedback_test.setText(‘RISPOSTA SBAGLIATA!’, log=False);
feedback_test.color=‘red’
feedback_test.height=0.05

Maybe it’s referring to the colour map. Check my crib sheet for how to set up colour variables.

1 Like

Yes you are right. I got old to program at night …
This is solution…
TY
green = new util.Color([-1, 0, -1]);
red = new util.Color([1, 0, 0]);

if ((response.includes(“z”)) && (matchT === 1)) {
feedback_test.setText(“RISPOSTA CORRETTA!”, {“log”: false});
feedback_test.setColor = green;
} else {
if ((response.includes(“m”)) && (matchT === 0)) {
feedback_test.setText(“RISPOSTA CORRETTA!”, {“log”: false});
feedback_test.color = green;
feedback_test.height = 0.05;
} else {
feedback_test.setText(“RISPOSTA SBAGLIATA!”, {“log”: false});
feedback_test.color = red;
feedback_test.height = 0.05;
}
}

1 Like