How does one go about scripting a sort of prismatic constraint that curves

i mean question is self explanatory im clueless as to where to start