// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Snap a point to a builder grid // Not compiled or tested in-world // Setup: Put in a spare prim you own. Edit POINT, ORIGIN, and STEP in metres, then touch. // Stop / restore: Disable or remove the script. It only reports to its owner and does not change prim properties. Reset clears its temporary state. // Notes: A positive step is required. Coordinates and origin must use the same coordinate frame. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Owner-only calculation; no scene changes. vector POINT = <2.13, -1.28, 0.66>; vector ORIGIN = <0.0, 0.0, 0.0>; float STEP = 0.25; vector snap(vector p, vector origin, float step) { vector q = (p - origin) / step; return origin + * step; } default { touch_start(integer detectedCount) { if (llDetectedKey(0) != llGetOwner()) return; if (STEP <= 0.0) { llOwnerSay("STEP must be positive."); return; } llOwnerSay("Snapped point: " + (string)snap(POINT, ORIGIN, STEP)); } changed(integer change) { if (change & CHANGED_OWNER) llResetScript(); } }