Description of the problem:
I am building the experiment using the psychopy builder, with large amounts of the experiment done in custon code objects. However, for some reason, after a certain point in the experiment, the automatically generated .js code stops reflecting what I’ve put in the builder, including not only stuff in the costum code objects but also other more traditional objects. See here an except of code from a custom code object in the “Each Frame” section
// Loop through keyboard events to update keyStates
let keyEvents = mykb.getEvents();
// Previous status of key we are currently watching
let previousStatus = status[currentKey];
// Key, timestamp, and keyDown, of current key event
let keyIndex, key, keyStatus;
for (let i = 0; i < keyEvents.length; i++) {
// Current key event
key = keyEvents[i].pigletKey;
keyStatus = keyEvents[i].status === Symbol.for('KEY_DOWN')? 'down': 'up';
// Index of this key in keysWatched. NB findIndex not supported by IE
keyIndex = keysWatched.indexOf(key);
// Key is one that we watch; update its status
if (keyIndex !== -1) {
status[keyIndex] = keyStatus;
statusList.push(keyStatus)
}
}
This code continues for a fair few lines
But then see here the complete function for this bit object - routine_2afc_stimRoutineEachFrame
function routine_2afc_stimRoutineEachFrame() {
return async function () {
//------Loop for each frame of Routine 'routine_2afc_stim'-------
// get current time
t = routine_2afc_stimClock.getTime();
frameN = frameN + 1;// number of completed frames (so 0 is the first frame)
// update/draw components on each frame
// *psych_phase* updates
if (t >= 0.0 && psych_phase.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
psych_phase.tStart = t; // (not accounting for frame time here)
psych_phase.frameNStart = frameN; // exact frame index
psych_phase.setAutoDraw(true);
}
if (psych_phase.status === PsychoJS.Status.STARTED && Boolean(psych_complete)) {
psych_phase.setAutoDraw(false);
}
// *psych_fixation_cross* updates
if (t >= 0.0 && psych_fixation_cross.status === PsychoJS.Status.NOT_STARTED) {
// keep track of start time/frame for later
psych_fixation_cross.tStart = t; // (not accounting for frame time here)
psych_fixation_cross.frameNStart = frameN; // exact frame index
psych_fixation_cross.setAutoDraw(true);
}
if (psych_fixation_cross.status === PsychoJS.Status.STARTED && Boolean(psych_complete)) {
psych_fixation_cross.setAutoDraw(false);
}
// check for quit (typically the Esc key)
if (psychoJS.experiment.experimentEnded || psychoJS.eventManager.getKeys({keyList:['escape']}).length > 0) {
return quitPsychoJS('The [Escape] key was pressed. Goodbye!', false);
}
// check if the Routine should terminate
if (!continueRoutine) { // a component has requested a forced-end of Routine
return Scheduler.Event.NEXT;
}
continueRoutine = false; // reverts to True if at least one component still running
for (const thisComponent of routine_2afc_stimComponents)
if ('status' in thisComponent && thisComponent.status !== PsychoJS.Status.FINISHED) {
continueRoutine = true;
break;
}
// refresh the screen if continuing
if (continueRoutine) {
return Scheduler.Event.FLIP_REPEAT;
} else {
return Scheduler.Event.NEXT;
}
};
}
You can see it just has the boiler plate stuff.
Is there some length limit to the code that psychjs can automatically turn into actual .js code? Do I need to abandon the builder and work directly on the .js code base?