Howdy! I’ve been migrating a project I made in builder over to Pavlovia and got stuck on some of the libraries. I looked through the other posts on here and docs online but couldn’t figure out what I was missing. Thanks for any help!
The original Python:
import psychtoolbox as ptb
from psychopy import sound,event
mouse0 =event.Mouse(win=win)
I’m just trying to translate the event.Mouse(...)
over to JS, but nothing I do seems to work. The automatic translation is mouse0 = new psychoJS.eventManager.Mouse(...);
, but this throws an error when run (not a constructor).
Then I tried mouse0 = new Mouse(...);
per the docs here but was given the error that Mouse was not defined. As a last ditch I tried mouse0 = new core.Mouse(...);
which didn’t turn any errors, but returns a null object that I can’t use .isPressedIn()
with.
Additionally, I’m trying to use the Sound constructor to play a sound file. The original Python looks like this:
sound.Sound(word1).play()
I tried a few similar methods and couldn’t get it to run either; I’m assuming I’m doing the same thing wrong here too.
For additional context, I don’t have it importing any JS libraries; psychtoolbox
and psychopy
are both Python-specific, and I couldn’t find a reference as to what libraries I should be specifying within the JS. This might be what I’m doing wrong.
How do I instantiate these objects? Is there a good place to find more extensive code examples of all these? I appreciate the help!