// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Undo and redo a local setting // Not compiled or tested in-world // Setup: Put in a spare prim you own. Touch through a five-step repeating sequence. The setting exists only in script memory. // 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: History is capped at eight values. A new edit after undo truncates the old forward branch. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Owner-only calculation; no scene changes. list history = [0]; integer at; integer step; setValue(integer value) { history = llList2List(history,0,at) + [value]; ++at; if (llGetListLength(history) > 8) { history = llDeleteSubList(history,0,0); --at; } } default { touch_start(integer detectedCount) { if (llDetectedKey(0) != llGetOwner()) return; integer action = step % 5; ++step; if (action == 0) setValue(step*10); else if (action == 1) setValue(step*10); else if (action == 2 && at > 0) --at; else if (action == 3 && at < llGetListLength(history)-1) ++at; else setValue(step*10); llOwnerSay("Current=" + (string)llList2Integer(history,at) + "; history=" + llDumpList2String(history,",") + "; cursor=" + (string)at); } changed(integer change) { if (change & CHANGED_OWNER) llResetScript(); } }