URL of experiment:
Description of the problem: Hello! I am trying to insert a routine for a break after N trials (in my case 30) - I saw a previous post (Using code to insert pauses within loops) and used the code suggested there, adapted for my number of trials. I inserted it in the beginning of the Break routine, and it works perfectly well on Builder, but when testing on Pavlovia the routine appears after every trial rather than after the 30th trial only. I checked Gitlab and both snippets of code show in the files.
This is the Python code:
if not trials.thisN in [30]: # on most trials:
continueRoutine = False # don’t even start this routine
else:
print(trials.thisN)
and this is the JS code that Builder translated (Auto->JS selected):
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(trials.thisN, [30]))) {
continueRoutine = false;
} else {
console.log(trials.thisN);
}
Thank you!