// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Rotation detent sound // Not compiled or tested in-world // Setup: Add tick. Owner-touch arms, then rotate the object with an existing tool. // Stop / restore: Owner-touch the script prim to stop an active session before removing or resetting it. Loop state can survive script removal; use Stop sound in this prim if necessary. // Notes: Use licensed sounds in this prim. Audio is nearby, not private. Timer timing and asset loading are approximate; no sample synchronization is promised. Uses root forward heading and ignores nearly vertical forward directions. At most one cue per sample. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer active; integer sector; stop() { active=FALSE; llSetTimerEvent(0.0); llStopSound(); } default { touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(active) { stop(); return; } active=TRUE; sector=-1; if(active)llSetTimerEvent(0.25); } timer() { if(active) { vector f=llRot2Fwd(llGetRootRotation()); if(llFabs(f.z)>0.98)return; integer next=(integer)llFloor((llAtan2(f.y,f.x)+PI)/(TWO_PI/8.0)); if(next>7)next=7; if(sector>=0&&next!=sector&&llGetInventoryType("tick")==INVENTORY_SOUND)llPlaySound("tick",0.15); sector=next; } } }