// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Fit a trend line through paired values // Not compiled or tested in-world // Setup: Put in a spare prim you own. Edit alternating x/y numbers in DATA and 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 least-squares fit is descriptive, not predictive assurance. At least two pairs with varying x are needed; small samples can be unstable. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Owner-only calculation; no scene changes. list DATA=[0.0,1.2,1.0,2.9,2.0,5.1,3.0,6.8]; default { touch_start(integer detectedCount) { if (llDetectedKey(0) != llGetOwner()) return; integer length=llGetListLength(DATA); if (length<4 || length%2) { llOwnerSay("Need at least two x/y pairs."); return; } float n=(float)(length/2); float sx; float sy; float sxx; float sxy; integer i; for (i=0; i