Hi!
I work on a task where participants have to click on a specific sequence of blocks that were previously highlighted. Clicked blocks change their color after mouse click for 0.1 seconds. I adapted my code based on the following post: Forcing End of Routine One Second After Mouse Click
The code works fine, but not online. The following message appears: ReferenceError: endTime is not defined.
Here is my code block in each frame:
Python: for rec in rectangles: if mouse.isPressedIn(rec): rec.fillColor = "black" clicked = True if rec.name == corrAns: endTime = t thisExp.addData('correct', 1) else: thisExp.addData('correct', 0)
if clicked and t > endTime + 0.5: continueRoutine = False
I tried to replace t by core.Clock(). This does not work under normal conditions and also not online (see my code below; message: endTime is not a constructor)
I restructured my code. I put endTime = t after mouse.isPressedIn.
This code works, but not online. Here again I get the message that endTime is not defined.
It would be great if you had further ideas I could try.
Thank you very much!
Here is my code I used with core.Clock (with 0.1 ms added to endTime):
Python:
for rec in rectangles:
if mouse.isPressedIn(rec):
clicked = True
rec.fillColor = "black"
endTime = core.Clock()
if rec.name == corrAns:
thisExp.addData('correct', 1)
else:
thisExp.addData('correct', 0)
if clicked and core.Clock() > endTime + 0.1:
continueRoutine = False