// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Center a child between two named anchors // Not compiled or tested in-world // Setup: Use a spare nonphysical rezzed linkset; disable competing scripts and do not edit or relink during the preview. Put this in the root. Name two other children anchor_a and anchor_b. Owner-touch the child to preview; touch again to restore. // Stop / restore: Owner-touch again to restore before removing, resetting, relinking or transferring. Snapshots are memory-only; deletion/reset does not undo changes. Keep an untouched backup. // Notes: Copies only their midpoint. Both anchors must be distinct from the selected part; no root or avatar anchors. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Test on a spare copy first. integer selected; key identity; list original; default { touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(llGetAttached()||llGetStatus(STATUS_PHYSICS)||llGetLinkNumber()>1) { llOwnerSay("Use a nonphysical rezzed root."); return; } if(selected) { if(llGetLinkKey(selected)==identity)llSetLinkPrimitiveParamsFast(selected,[PRIM_POS_LOCAL,llList2Vector(original,0),PRIM_ROT_LOCAL,llList2Rot(original,1),PRIM_SIZE,llList2Vector(original,2)]); else llOwnerSay("Topology changed; restore manually from backup."); selected=0; return; } integer link=llDetectedLinkNumber(0); if(link<2||link>llGetObjectPrimCount(llGetKey())) { llOwnerSay("Touch a child prim."); return; } list data=llGetLinkPrimitiveParams(link,[PRIM_POS_LOCAL,PRIM_ROT_LOCAL,PRIM_SIZE]); vector p=llList2Vector(data,0); rotation r=llList2Rot(data,1); vector size=llList2Vector(data,2); integer i; integer a; integer b; integer ca; integer cb; integer total=llGetObjectPrimCount(llGetKey()); if(total>32)return; for(i=2;i<=total;++i) { if(llGetLinkName(i)=="anchor_a") { a=i; ++ca; } if(llGetLinkName(i)=="anchor_b") { b=i; ++cb; } } if(ca!=1||cb!=1||a==link||b==link) { llOwnerSay("Need two unique other anchor children."); return; } p=(llList2Vector(llGetLinkPrimitiveParams(a,[PRIM_POS_LOCAL]),0)+llList2Vector(llGetLinkPrimitiveParams(b,[PRIM_POS_LOCAL]),0))*0.5; selected=link; identity=llGetLinkKey(link); original=data; llSetLinkPrimitiveParamsFast(link,[PRIM_POS_LOCAL,p,PRIM_ROT_LOCAL,r,PRIM_SIZE,size]); llOwnerSay("Preview applied; touch again to restore."); } changed(integer flags) { if(flags&CHANGED_OWNER)llResetScript(); } }