Edit: To put this problem simply, I need to replace a word on the screen with a new word from an array when either a participant responds by pressing the spacebar or when 4 seconds is up, whichever comes first. The word replacement needs to happen in the same routine (so the keyboard press cannot end the routine).
I am attempting to create a dual-task experiment where on one half of the screen, a video plays continuously while on the other half of the screen, words appear. As the video plays, the user has four seconds to respond with the keyboard to the word that appeared. The next word appears when they respond or when the 4 seconds is up. The video needs to continue to play the entire time this is occurring without starting over. However, the video may terminate if the user presses an on-screen button. The routine should end when the video is over or when the button is pressed.
The main issue is that in the regular builder, I cannot seem have a user response terminate one stimuli without terminating the other. I have been working in the coder and searching the forum, and believe I have come up with the logic for what I need, but I am not sure how to best implement it.
The experiment currently has two routines for bringing the stimuli in. The first routine uses code to read in the words and put them in an array, then randomly shuffles them for presentation. The second routine does the same for the video files. Then, the routine that shows the stimuli is in a loop called “trials”, which is presenting both stimuli with seperate timing. However, the word disappears after 4 seconds if there is no response, but then that side of the screen stays blank until the time for the video is up, rather than presenting another word. If there is a response to the word, it ends the entire routine (so a new video starts playing).
The logic that I have come up with would be as follows, and it would go in the looped routine under the frames tab (note that I have made up variable names based on what I am looking for, this is no type of actual code).
while currentTime <= videoTime
if wordResponse = True:
showNextWord
if wordTime = 4:
showNextWord
If this logic is correct, suggestions on how to actually implement it would be appreciated. If there is an easier way to do this, please let me know.
Thank you!