I’m trying to refer to some variables from a previous trial in a new trial using a code component, and I keep running into problems - likely because I’m not using the getEarlierTrial() function quite right. I’m trying to store the location of a previous target on the screen (each location is stored in two variables: x_pos and y_pos, saved to the output file at the start of each routine) in the next trial, so that I can compare the distance between the two.
Right now, I have the following at End Routine:
last_x_loc = experimentName.getEarlierTrial(n=-1)['x_pos.routineStartVal'] last_y_loc = experimentName.getEarlierTrial(n=-1)['y_pos.routineStartVal']
Where last_x_loc and last_y_loc are initialized variables. Is there a more elegant way to do this?
Thanks in advance!