Alright, I’ve found the solution and I’ll explain it here so that people won’t need to download any files. You start by creating a ‘while’ loop with the condition IN[port] == False.
In each iteration of the loop, move the robot incrementally in the negative z-direction, with tz = -1, from the base_1 position you have set up.
After each movement, adjust the base one level lower to ensure the loop functions correctly.
It’s important to reset the base to its original position at the end of the loop, which isn’t done in the current program. Perhaps you could implement a counter to track the movements and then reposition the base accordingly. Thanks, BAD."