// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Limit a displacement without changing direction // Not compiled or tested in-world // Setup: Use a spare owned prim. Set DISPLACEMENT and positive MAXIMUM. Touch for owner-only results. // Stop / restore: Disable/remove. No scene properties change. // Notes: Useful as a reusable movement-budget calculation; no actual movement occurs. // License: see LICENSE in this distribution. // Original Incoprea. MIT. vector DISPLACEMENT=<8.0,6.0,1.0>; float MAXIMUM=4.0; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(MAXIMUM<0.0) { llOwnerSay("Maximum cannot be negative."); return; } vector result=DISPLACEMENT; float length=llVecMag(result); if(length>MAXIMUM&&length>0.0)result*=MAXIMUM/length; llOwnerSay("Limited displacement="+(string)result+"; retained fraction="+(string)(llVecMag(result)/(length+0.000001))); } }