// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Project child onto an authored rail // Not compiled or tested in-world // Setup: Set A and B. Put in nonphysical child; owner-touch previews/restores. // Stop / restore: Owner-touch again to restore the startup snapshot before removal or reset, unless setup describes a different cycle. Do not relink during a preview. // Notes: Use a spare modifiable build. Saved state lives only in script memory. Centerline alignment, not a moving constraint. Degenerate endpoints rejected. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer preview; vector A=<-1.0,0.0,0.0>; vector B=<1.0,0.0,0.0>; vector home; default { state_entry() { home=llGetLocalPos(); } touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(llGetLinkNumber()<2||llGetStatus(STATUS_PHYSICS)||llVecDist(A,B)<0.001)return; preview=!preview; if(preview) { vector d=B-A; float t=((home-A)*d)/(d*d); if(t<0.0)t=0.0; if(t>1.0)t=1.0; llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL,A+d*t]); } else { llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL,home]); } } }