// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Split a calculation across events // Not compiled or tested in-world // Setup: Put in a spare prim you own. Touch once to start. Further touches report busy until completion. // 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: The arithmetic is intentionally small; the pattern shows bounded work per event rather than a long loop or sleep. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Owner-only calculation; no scene changes. integer cursor; integer total; integer running; default { touch_start(integer detectedCount) { if (llDetectedKey(0) != llGetOwner()) return; if (running) { llOwnerSay("Calculation already running."); return; } running = TRUE; cursor = 1; total = 0; llSetTimerEvent(0.25); } changed(integer change) { if (change & CHANGED_OWNER) llResetScript(); } timer() { integer batch; for (batch = 0; batch < 10 && cursor <= 100; ++batch) { total += cursor*cursor; ++cursor; } if (cursor > 100) { running = FALSE; llSetTimerEvent(0.0); llOwnerSay("Sum of squares 1..100: " + (string)total + " (expected 338350)."); } } }