I’m adjusting someone else’s code to modify one piece of a trial structure. Right now there is a sequence that runs each trial, and the times for each component are fixed, using Wait. I’d like to modify it so that during the ‘test’ function, if the user presses a specific key (probably spacebar), it will move on to the next function in the sequence (‘iti’). If the spacebar is not pressed, I want it to still just wait 8 seconds and then move on to the next function in the sequence.
I tried adding an interval, with no luck. This code also has some associated world base code, and I’m only attaching the sequence part, and the information about what is in the ‘test’ function, but I can add more if that is helpful. Since I didn’t build this originally, I’m not sure of all the details of the code, but any suggestions would be appreciated!
# Assemble the trial.
trial_seq = Sequence(Func(self.setStage, 'map', trial),
Wait(2.0),
Func(self.setStage, 'fixation'),
Wait(4.0),
Func(self.setStage, 'test', trial),
Wait(8.0),
Func(self.setStage, 'iti'),
Wait(trial['iti']),
name="Trial")
self.runSequence.append(trial_seq)
self.runSequence.append(Func(self.setTracing, trace, False))
self.runSequence.append(Func(self.userExit))
if name == 'test':
self.activateActorOIControl(True)
self.setBackgroundColor(self.skyColor)
self.activateDisplayRegion('default', True)
self.activateCamera(trial['camera'])
if trial['camera'] == 'TPV':
self.cameraNP['TPV'].setPos(self.actorOINP, (0,-5,5))
self.getObject('Goal')[0].hide()
self.getObject('Start')[0].hide()
self.markLogFile('TEST')
self.traceUpdateFunc = self.testTraceMessageFunc