Hello! I’m trying to make a feedback loop saying “Too Slow!” only when they take longer than 1.5 seconds to respond, but it keeps crashing and I’m new to this so would appreciate some help
This is the code I’ve put in the begin routine tab: (my text response component is called response1)
if response1.rt > 1.5:
continueRoutine = True
else:
continueRoutine = False
When I run it it works fine skipping the routine but when it takes longer than 1.5s it crashes and says this instead of showing the message:
TypeError: ‘>’ not supported between instances of ‘list’ and ‘float’
put this in the Begin Routine tab. Place the code-element above your text-element, displaying the feedback message, set the text of your feedback text-element to $msg, and set the text to set every repeat.
I suspect that you are storing all responses in your keyboard component. That would make response1.rt a list. For the most recent rt you need response1[-1].rt
Alternatively, change the routine to only store one response.
However, you also don’t need continueRoutine=True, just have
Hi I encountered the error of ‘TypeError: ‘Keyboard’ object does not support indexing’ when implementing similar codes if respKey[-1].rt <= 1.5: msg="too slow"
in the Begin Routine. Any suggestion? Thanks!
Using respKey.rt[-1] gave me another error message of “IndexError: list index out of range”, any idea? thanks
ps. thanks for noticing it, I used <=1.5 to debug to show the ‘too slow’ faster
My attempts have been revised here (sorry not yet successful but found some consistent errors): I tried moving this section of code from Begin Routine to Each Frame, but I still get the error ‘TypeError: ‘Keyboard’ object does not support indexing’ when I use respKey[-1].rt (also try [0], same error output). Index rt using respKey.rt[-1] (also tried [0]) returned “IndexError: list index out of range.”
the keyboard component is ‘respKey’.
Perhaps the issue is that the code (tooSlow, see image below) is located in the current response (resp) routine? I store the last key in the respKey properties and allow three letters that correspond to the $correctAns. The text component used to display the ‘Response too slow’ message on each repeat. The preceding routine is displayed in the image below (showing on the screen 0.15s, no other components in this routine, as well as for fixation)