Hi everyone,
Just to tell to anyone that might be interested in this topic that I had some help and the solution is as follows:
- in the component code, in Begin Routine tab add:
sentenceTREINOList = sentenceTREINO.split("/");
wordNumber = (-1);
- in Each Frame tab add:
var _pj;
function replaceWithX(textList, currentWordNumber) {
var index, result, word;
result = "";
index = 0;
while ((index < textList.length)) {
word = textList[index];
if ((index !== currentWordNumber)) {
result = ((result + ("_".repeat(word.length))) + " ");
} else {
result = ((result + word) + " ");
}
index = (index + 1);
}
return result;
}
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);
text_10.text = replaceWithX(sentenceTREINOList, wordNumber);
keypresses = event.getKeys();
if ((keypresses.length > 0)) {
if (_pj.in_es6("space", keypresses)) {
thisResponseTime = t;
wordNumber = (wordNumber + 1);
if ((wordNumber < sentenceTREINOList.length)) {
if ((wordNumber === 0)) {
timeOfLastResponse = 0;
}
thisExp.addData(("IRI_TREINO_" + wordNumber.toString()), (thisResponseTime - timeOfLastResponse));
timeOfLastResponse = thisResponseTime;
text_10.text = replaceWithX(sentenceTREINOList, wordNumber);
} else {
continueRoutine = false;
}
} else {
if (_pj.in_es6("escape", keypresses)) {
core.quit();
}
}
}
As mentioned on the previous post, I also added the code component @wakecarter suggests in his Crib Sheet at the beginning of the experiment.
Now the experiment runs perfectly in Pavlovia.
Thank you very much.
Paula