| Reference | Downloads | Github

Re-writing code snippet for self-paced reading experiment in JS

I am trying to run a self-paced reading experiment online using PsychoPy3. I’ve created the experiment in Builder and after reading information on this forum (from posts by @dvbridges) used some code snippets that help simplify the design and keep track of the reading times for each word presented. The experiment works well in Builder but when I try and host it on Pavlovia it does not automatically convert the custom code snippets to JS. I was wondering if anyone could help me do that?

Here is the code that I have inserted in my trial routine in Python:

Begin Routine tab:

# create a list of individual words by splitting up the 
# sentence variable at each space character: 
word_list = Sentence.split() 
word_list.reverse() # switch the order 
rtList = []

Each Frame tab:

while continueRoutine:
    kb = event.getKeys(timeStamped=True)
    if len(kb) > 0:
        if 'space' in kb[0]:
                nextWord = word_list.pop()
            except IndexError:
                continueRoutine = False
        if 'q' in kb[0]:

End Routine tab

rtList = np.ediff1d(rtList)
for rts in range(len(rtList)):
    thisExp.addData('word_{}'.format(rts), rtList[rts])

Any help would be much appreciated!