Second Life aujourd’hui en un seul endroit Cadeaux et freebies mis à jour chaque heure 7 langues Gratuit pour inscrire votre boutique
Incident grille
  • Prévu: Scheduled Billing Maintenance, lun. 16 nov. 09:30–10:30 SLT
  • État de la grille: Unscheduled Group Chat Maintenance (investigating)
  • En ce moment: Office du samedi Unitarian Universalist à UUtopia
  • En ce moment: The Dharma of Community : société bouddhiste et householder
  • En ce moment: SLCS Harvest Fest : jeux, musique et amusement
  • 14:00 SLT: NAD GOUGH en live au Moondance à Cascadia, 14 h SLT
  • Actus: REZZ MALL : les marques Second Life dans un centre commercial web
  • Viewer: Second Life Viewer 26.5 modernise le chat
  • Prévu: Scheduled Billing Maintenance, lun. 16 nov. 09:30–10:30 SLT
  • État de la grille: Unscheduled Group Chat Maintenance (investigating)
  • En ce moment: Office du samedi Unitarian Universalist à UUtopia
  • En ce moment: The Dharma of Community : société bouddhiste et householder
  • En ce moment: SLCS Harvest Fest : jeux, musique et amusement
  • 14:00 SLT: NAD GOUGH en live au Moondance à Cascadia, 14 h SLT
  • Actus: REZZ MALL : les marques Second Life dans un centre commercial web
  • Viewer: Second Life Viewer 26.5 modernise le chat
Script LSL

LSL sound loop script for ambient sound

Free LSL ambient sound script for Second Life: loop birds, waves, rain or a fire crackle from any object, set the volume and touch to turn it on and off.

52 lignes ·

Sound brings a place to life: waves on a beach, birds in a garden, a crackling fireplace. This sound loop script plays a sound on repeat from any object, with a volume setting and touch to switch it on or off.

lsl-sound-loop-script.lsl · 52 lignes Vérifier ce script
// Ambient Sound Loop - free LSL script from WhatSL (https://whatsl.com/scripts/lsl-sound-loop-script)
// Free to use, change and put in your own creations, also ones you sell.
//
// Plays a sound on repeat: birds, waves, a fire, rain, a shop jingle.
// Put a sound in the object's Contents (or paste a sound UUID into SOUND_NAME). Touch to turn it on and off.

string  SOUND_NAME   = "";    // "" = the first sound in Contents; or a sound name or UUID
float   SOUND_VOLUME = 0.6;   // 0.0 to 1.0; keep ambient sounds soft
integer START_ON     = TRUE;
integer OWNER_ONLY   = FALSE; // TRUE = only the owner can turn it on and off

integer gOn = FALSE;

string soundToPlay()
{
    if (SOUND_NAME != "") return SOUND_NAME;
    return llGetInventoryName(INVENTORY_SOUND, 0);
}

setSound(integer on)
{
    llStopSound();
    gOn = FALSE;
    if (!on) return;
    string snd = soundToPlay();
    if (snd == "")
    {
        llOwnerSay("Put a sound in my Contents, or set SOUND_NAME.");
        return;
    }
    llLoopSound(snd, SOUND_VOLUME);
    gOn = TRUE;
}

default
{
    state_entry()
    {
        setSound(START_ON);
    }

    touch_start(integer total)
    {
        if (OWNER_ONLY && llDetectedKey(0) != llGetOwner()) return;
        setSound(!gOn);
    }

    changed(integer change)
    {
        if (change & CHANGED_INVENTORY) setSound(gOn);
    }
}

Libre d’utilisation, de modification et d’intégration dans vos créations, même celles que vous vendez.

How to set it up

  1. Put a sound into the object's Contents (or copy a sound's UUID).
  2. Add the script and save. The sound starts playing.
  3. Touch the object to stop it and touch again to start it.

Settings

  • SOUND_NAME: empty plays the first sound in the Contents. You can also type a sound name or paste a sound UUID.
  • SOUND_VOLUME: 0.0 to 1.0. Ambient sounds sound best soft, around 0.3 to 0.6.
  • START_ON: whether the sound plays as soon as the script starts.
  • OWNER_ONLY: TRUE stops visitors from switching it off.

Tips

  • Use sounds that are made to loop, without a gap or click at the end.
  • Visitors hear the sound near the object. Place several quiet sources around a big area rather than one loud one.
  • For music for a whole parcel, use the parcel's music stream instead of a sound loop.

Frequently asked questions

Why can't I hear anything?

Check that sound effects are turned up in your viewer's volume controls, that the object has a sound in its Contents, and that you are close enough to the object.

Can I play several sounds in a row?

This script loops one sound. Playing a list of sounds needs llPlaySound with a timer for each clip.

Does a sound loop cause lag?

Very little. The region tells viewers to loop the sound once; the viewer does the rest.

Vérifier votre propre script: Vérificateur de syntaxe LSL →

Autres scriptsTous les scripts
Script LSL · 55 lignes

Script de porte LSL : toucher pour ouvrir, se referme seule

Script de porte LSL gratuit pour Second Life. Touchez pour ouvrir et fermer, la porte pivote sur ses gonds et se referme toute seule après quelques secondes. Sons facultatifs.

Script LSL · 69 lignes

LSL sit and pose script for chairs and pose balls

Free LSL sit script for Second Life chairs, benches and pose balls: sit and play your own animation, set the sit position, hide the ball while in use.

Script LSL · 96 lignes

LSL tip jar script with thank-you message and total

Free LSL tip jar script for Second Life clubs, DJs, hosts and stores: quick pay buttons, a thank-you message, the total and last tipper in floating text.