Moving through routines with left and right arrow key

Dear all,

I have a question relating to moving through instructions/routines for my experiment. The instructions are quite complex and long (12 routines) and there are loops in some routines already. The question is very similar to this thread: Can you move backward through routines?

What am I trying to achieve?
I want to be able to move through routines with the left and right arrow key without doing everything in 1 routine. The reason for this is because I have routines with pictures in a lot of different places and text in various places.

What did you try to make it work?
For one routine I am going through 9 pictures with the example of the thread I am directing to above. This works perfectly.

I am wondering whether there is the option to actually move through different routines and whether somebody may have an example of this.

Warm regards,

Snoek

1 Like

I have to say that the easiest thing to do here would be to lay out the text and images for each instruction page and take a screenshot of the whole lot. Then you can just have the arrangement of a single routine with a single changing image on each iteration of a single loop.

1 Like

Thank you for your reply @Michael, it is much appreciated. This seems like a reasonable solution. I do have some clickable stimuli at one point, as I have a questionnaire to see whether participants have understood the instructions. This test/questionnaire exists out of two routines with around 6 questions per routine. Once they have filled in the right questions they can move on. I could stop the loop before this, however, I guess I would then need a button that can make them go back to the loop with the instructions when they would want to read the instructions again to answers the questions. I am not sure whether this is possible.

I also have a routine where instructions are shown for a certain amount of time (I am giving them an example of what the participant they are doing the task with will see), which may also make this complicated as this is not self-paced but is in the middle of these instructions.

I was also wondering about if I would make screenshots and then insert them as images in a routine, would this not be affected by what type of screen the participant would use as I am planning on using Pavlovia for the experiment?’

As Michael says, having just one routine would be easier. However, if really necessary, it is possible to also move back and forth through routines. Please find an example attached. The basic idea is to have x routines, each with a loop around them, plus an outer loop. For each outer loop iteration, only one of these routines will be presented. The response then determines which routine is presented on the next iteration of the outer loop. If the response is left, the previous routine will be presented and if the response is right, the next one. Which routine is presented is controlled by a list, the elements of which are used in the repeat settings of the inner loops. In the example with 3 routines, [0,1,0] means that the second routine will be presented. If the response is right, this changes to [0,0,1] and the third routine will be presented. If the response is left, this changes to [1,0,0] and the first routine is presented.
Please note that the example is still missing is a piece of code to break out of the outer loop after the final trial.

Jan

routines_back_and_forth.psyexp (20.2 KB)

2 Likes

For folks who want to get this working online, you’ll need to do a little manual py > js.

You can use @jderrfuss psyexp example above, and then in the code component in “dummy” routine, change Code Type to “both”, and replace the js side in Begin Routine with this:

 if ((lastResponse === "right")) {
    ele = loopRepeats.shift((- 1));
    loopRepeats.unshift(0, ele);
} else {
    if ((lastResponse === "left")) {
        ele = loopRepeats.shift(0);
        loopRepeats.push(ele);
    }
}

cheers!

2 Likes

Hi Jan,

I’ve used your code to move back and forward between routines (thank you for the template!) and I’m running into an issue - the left arrow key, instead of moving backwards through routines, moves forward, similar to the right arrow key. I triple checked copying your code properly and I’m unsure how to proceed. Any tips? Thank you in advance!

Ann

Never mind, I figured it out! Neglected to change the number of reps across the routines.