Hi,
in the experiment the subject produces circles by holding the space bar as u can see below:
when i run the code in the offline lab, it takes about 6 sec to fill up the hole big circles with dots, but when i run the code online, it takes 2 sec,
To maintain equality in times I wanted to use Python’s core.wait code only in javascript.
I saw topics that suggested using: setTimeout, setInterval.
My question is how to infuse this function into my code? This is the code in each frame tab that produces the circles and displays them:
//show the circles on the screen
for (var circle, _pj_c = 0, _pj_a = Circle_List, _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
circle = _pj_a[_pj_c];
circle.setAutoDraw(true);
}
// If any key events are present
let keyEvents = kb.getEvents();
if (keyEvents.length > 0) {
if (keyEvents[keyEvents.length-1].pigletKey === 'space' && keyEvents[keyEvents.length-1].status === Symbol.for('KEY_DOWN')) {
switched = false;
if (space_func ) {
// selected_Values[i][0]
// make a circle
// add it to the list
if (i < (selected_Values.length-1)) {// only add this circle to be drawn if we haven't yet hit the max
var polygon = new visual.Polygon({"win": psychoJS.window, "name": "polygon", "units": "height", "edges": 100, "size": selected_Values[i][0], "ori": 0.0, "pos": [selected_Values[i][1], selected_Values[i][2]], "lineWidth": 0, "colorSpace": "rgb", "lineColor": "white", "fillColor": "black", "opacity": null, "depth": 0.0, "interpolate": true});
Circle_List.push(polygon);// add a circle to the draw list
// increase the iteration
i += 1;
}
}
else {
if (i > 0){
var Cir_Pop = Circle_List.pop();//remove a circle from the draw list
Cir_Pop.setAutoDraw(false);
i -= 1;
}
}
}
else {
if (keyEvents[keyEvents.length-1].pigletKey === 'space' && keyEvents[keyEvents.length-1].status === Symbol.for('KEY_UP') && ! switched) {
if (space_func){
space_func = false;
}
else{
space_func = true;
}
switched = true;
}
}
}