I managed to make my own custom variables and increment them in order to track accuracy BUT the issue I have now is the above:
In the Learning_feedback routine, Begin Experiment Tab, I have this JS code component:
msg_2 = "";
Acc_blocks=0;
Acc_trials=0;
my_trial=0;
In the Learning_feedback routine, Begin Routine Tab, I have this JS code component:
if (mouse_2.clicked_name.includes("Star", "Learning_scenes")) {
msg_2 = "Got it!";
Learning_loop.addData("Accuracy", "1");
Acc_blocks=Acc_blocks+1;
Acc_trials=Acc_trials+1;
} else if (mouse_2.clicked_name.includes("Learning_scenes")){
msg_2 = "Nope.";
Learning_loop.addData("Accuracy", "0");
} else {
msg_2 = "Time's up";
Learning_loop.addData("Accuracy", "-");
}
my_trial=my_trial+1;
console.log(mouse_2.clicked_name);
console.log(my_trial);
Then on the Trial_Break routine, Each Frame Tab, I have this JS code component:
if (my_trial !== 24 && my_trial !== 48 && my_trial !== 72) {
continueRoutine = false;
msg_3="You completed 24 trials! You found " + Acc_trials + " out of 24 targets";
}
The problem is that even if I find all the targets in 24 trials (which means 24 targets), it says that I got only 23. For some reason, it omits the performance on the last trial. I inserted a “fake” routine in between (called gap) to console.log(Acc.trials) and it shows the right accuracy but when it moves to the next routine which is the Trial_Break and has to display the Accuracy it shows the wrong number. What is missing here???