How to staircase based on a threshold

Hi all,

I am attempting to code an adaptive staircase. I realize you can do an adaptive staircase in builder, but my experiment staircases a stimulus in one routine based on a response on a different routine, so I think coding it out is the way to go. I want the experiment to add 0.015 seconds to stimulus timing if the response is incorrect, and to subtract 0.015 seconds if the response is incorrect. I have the following code:

if key_resp_2.corr:
    time = time - 0.015
    
else:
    time = time + 0.015

This works great, but obviously there isn’t a cut off threshold for presentation time. I’ve done a little digging on how to add some code for a threshold (my desired is max 0.250 seconds, min 0.100 seconds), but I’m still lost. Does anyone have any tips on how to proceed?

if key_resp_2.corr:
    if time > .1:
        time = time - 0.015
else:
    if time < .25:
        time = time + 0.015

There are more elegant ways of doing it but this is the simplest. It just won’t modify the value of time unless it’s within those boundaries.