// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Four-level ambient volume // Not compiled or tested in-world // Setup: Add a licensed loop named ambience to this prim. Owner-touch cycles 0.1, 0.2, 0.35, and off. // Stop / restore: Touch until Off appears in owner chat, then remove. // Notes: Controls attached sound in the prim containing the script. Another script playing sound here can interfere. // License: see LICENSE in this distribution. // Original Incoprea example. MIT. Not compiled or tested in-world. string SOUND = "ambience"; list levels = [0.0, 0.1, 0.2, 0.35]; integer level; default { touch_start(integer count) { if (llDetectedKey(0) != llGetOwner()) return; if (llGetInventoryType(SOUND) != INVENTORY_SOUND) { llOwnerSay("Add a sound named ambience."); return; } integer previous = level; level = (level + 1) % 4; float volume = llList2Float(levels, level); if (!level) { llStopSound(); llOwnerSay("Off"); } else { if (!previous) llLoopSound(SOUND, volume); else llAdjustSoundVolume(volume); llOwnerSay("Volume: " + (string)volume); } } }