[open] Set time limit for loop
Hi,
I would like to set a one minute time limit for a loop, is that possible. If yes, how do I do this?
Thanks!
Hi,
I would like to set a one minute time limit for a loop, is that possible. If yes, how do I do this?
Thanks!
Comments
Of sorts, yes. A
loopcannot be aborted halfway, but you can use a break-if statement (under 'Show advanced options') to prevent aloopfrom starting a new cycle.Let's say that you have a structure like this:
You can then make use of the fact that most items have a
time_[item name]variable that contains the time that the item was last executed. To break theloopafter 5 s, you could use a Python-style break-if statement like this:Basically, this means that the
loopshould be aborted if the timestamp of sketchpad is more than 5000 ms later than the timestamp of start_marker. In addition, we make sure that the variabletime_sketchpadactually exists (withself.has()) otherwise we get an error at the first iteration of the loop, when sketchpad has never been executed yet.Does that make sense?
For more information about if statements and variables, see:
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!