Simple coroutine question
Hello,
The coroutine function is fantastic, but I'm not able to get the coroutine to end after a button press. Basically I present a stimulus for 500ms, it is replaced by a blank screen for up to 1500ms (before a 2000ms timeout - and this is where the coroutine function came in handy). But I've tried setting the duration of the coroutine to 'keypress' and it doesn't seem to work - am I missing something very obvious?
Thank you!
Comments
Hi,
That's an interesting question. Right now, coroutines has a fixed duration. But what you could do is define your own generator function in an inline_script that
Like so:
You'd then add 'break_coroutines' in the 'Generator function name' field of the coroutines plug-in.
It's a bit of a hack though ... I'll see if I can think of a more elegant way to do this.
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Great thank you! I will give it a shot and let you know how it goes.
Best,
Mikael
Hi Sebastiaan,
So I am getting a 'zero division error' - float division by zero. It seems like the loop in the inline script isn't working: if I set items['my_coroutines'].var.duration = 1 then I see subsequent trials for 1ms, so the script is not only applying the 'set coroutines duration to 0' to a single trial, but to every subsequent trial.
Ow right! You need to set duration back to its original value before the coroutines is started. To do so, you can add an inline_script immediately before the coroutines plug-in, with the following code in it (either in the Run or Prepare phase):
Check out SigmundAI.eu for our OpenSesame AI assistant!
Works great! I placed it in the prepare phase of the main script you passed along - a super useful fix!