End the routine at a specific position for polygons that move in different directions every routine

What are you trying to achieve?:
I set the polygon’s X coordinate to (Dir1+((Dir2)t+(Dir3)(-4.0))*Velocity,0). Dir1 Dir2 Dir3 Velocity is set in Excel.
With this setting, I want to move Polgon routinely from left to right and from right to left.
I have set the below code in code component.

if Dir1+(Dir2t+(Dir3)(-4.0))Velocity>=-2.7:continueRoutine=True
else:continueRoutine = False
if Dir1+(Dir2
t+(Dir3)*(-4.0))*Velocity<=2.7:continueRoutine=True
else:continueRoutine = False

What specifically went wrong when you tried that?:
With above code, the movement from left to right will end the routine at a specific X coordinate. this is good. However, the right-to-left movement routine is not presented in the first place.

I dont understand what to do.

my problem was solved!!

the python code I wrote is bellow.

if Dir1 == -2.7 and Dir1 + Dir2 * (t - 1) * Velocity >= -2.7:
continueRoutine = True

if Dir1 == -2.7 and Dir1 + Dir2 * (t - 1) * Velocity > 2.7:
continueRoutine = False

if Dir1 == 2.7 and Dir1 + Dir2 * (t - 1) * Velocity <= 2.7:
continueRoutine = True

if Dir1 == 2.7 and Dir1 + Dir2 * (t - 1) * Velocity < -2.7:
continueRoutine = False

Dri1 and Dri2 and Velocity are set in excel.
This code make polygon move from right to left or from left to right, and it is stopped at speciffic position.