I am trying to build an approach avoidance task, the response time should be the time from stimulus onset to the first mouse movement. Sadly, I cannot find any option in the builder which makes it possible to save the time of the first mouse movement.
I am not the best at coding, but maybe you can help me to write a code snippet which helps me to save the time of the first mouse movement. Furthermore, would it be possible to transfer this to an online experiment in Pavlovia?
A number of my demos save the position of the mouse in Begin Routine and then check for a movement each frame. Have a look at the ones designed for mobile devices.
I’m on my phone so not inclined to write out the code for you now.
if moved == False:
mouseloc = mouse.getPos()
if mouseloc[0] != mouserec[0] or mouseloc[1] != mouserec[1]:
moved = True
thisExp.addData('Moved',round(t*1000))
It should definitely work online, since it’s based on the code I use for online. It just needs a mouse component called mouse (I usually put one in my first routine – it doesn’t have to be in the same routine as the code).
Maybe you can also help me with the following, I am now trying to implement feedback based on a variable in my conditionsfile (TargetPosition) and based on the position of the mouse on the y-axis.
I tried the following, but it is not working yet:
if ((TargetPosition == 'left') and ('mouse.y' < 0)) or ((TargetPosition == 'right') and ('mouse.y' > 0)):
msg = 'wrong'
I get this error message:
if ((TargetPosition == 'left') and ('mouse.y' < 0)) or ((TargetPosition == 'right') and ('mouse.y' > 0)):
TypeError: '>' not supported between instances of 'str' and 'int'