Participants’ task: use mouse to click 1 out of 4 pictures;
Exp’s task: compare the selected picture with the target in condition file
–correct coded as 1,
–incorrect coded as 0.
Offline PsycoPy–able to run
I wrote the code in the builder’s view, and it succeeded in generating correct response=1, incorrect response=0;
[“clicked” and “score” are newly generated columns according to “thisExp.addData(‘clicked’, imageTestX)”, and “thisExp.addData(‘score’, int(correctAcc2==imageTestX”]
Online Pavlivia–unable to run
After transerring the exp in builder’s view onto Pavlovia, I met the following error:
“TypeError:mouse_record. isPressedIn is not a function”
isPressedIn doesn’t really work in Pavlovia, but there is an alternative approach. Unfortunately I think it requires manually programming the javascript in the code component rather than using auto->JS, so set your code type to “Both”.
The key thing is that instead of using mouse.isPressedIn(object), you need to use object.contains(mouse). See here for an example (the rest of the thread is about a mostly unrelated problem): TypeError: Cannot read property 'addChild' of undefined
I have tried both of your suggestions:
a. after setting code type to “Both”, it still shows the same error
[which means it may need manual coding as you suggested]
b. after changing from “if mouse_record.isPressedIn(image_1):” into “if image_1.contains(mouse_record):”, the error disappeared–“TypeError: mouse is PressedIn is not a function”.
[which means “object.contains(mouse)” works. Thank you.]
However, I encountered another error afterwards, which should be attributed to addData code:
exp.addData(‘clicked’, imageTest1)
exp.addData(‘score’, int(correctAcc == imageTest1))
That one is easy to fix, just replace “exp.addData” with “psychoJS.experiment.addData”, it will add the data to the trial handler for the trial containing that code component.