-->

FoxSan's 3D Tools and LSL Script Repository

Tons of LSL scripts, examples and 3D tools, free for all. There are currently 207 scripts and articles in this database.

Play Script (with sound files)

integer nombre ;
integer numero;
 
default {
    state_entry() {
        // lorsque le script passe dans son état par défaut.
        // un “OFF” rouge apparaüt au dessus de la prim
        llSetText("", <1,0,0>, 1.0);
        llSetPrimitiveParams([ PRIM_FULLBRIGHT, ALL_SIDES ,FALSE]);
        nombre = llGetInventoryNumber(INVENTORY_SOUND);
         llStopSound();
    }
    touch_start(integer num_detected) {
        // quand la prim est touchĂ©e, le script passe dans l’état 'on'
        state on;
    }
}
 
state on {
    state_entry() {
        // Lit ce code lorsque le script passe dans l’état ‘on’
        // un "ON" vert apparaĂźt au dessus de la prim
        llSetPrimitiveParams([ PRIM_FULLBRIGHT, ALL_SIDES ,FALSE]);
 
        numero = 0;
        llSetSoundQueueing(TRUE);
        llSetTimerEvent(0.01);
 
    }
    timer()
    {
        llSetTimerEvent(10.0);
        llTriggerSound(llGetInventoryName(INVENTORY_SOUND,numero), 99.5);
        numero = numero + 1;
        if(numero>= nombre) numero = 0;
        llPreloadSound(llGetInventoryName(INVENTORY_SOUND, numero));        
 
    }
    touch_start(integer num_detected) {
        // quand la prim est touchĂ©e, le son s’arrrĂȘte et le script retourne dans son Ă©tat par dĂ©faut
        llStopSound();
        state default;
    }
}

Ambient sound

// Ambient Sound script by Alfkin Small.
 
// To use: Place this script in the object that you want to play a sound.
// The object need not be special.  Just place is where you want the sound
// to come from.
// Drop a sound file in the object, then change the key sound line below to
// the name of your sound file.
// If you like, you can set the min and max values as well, in addition to
// the volume.  That's all there is to it!
 
// Set debug to TRUE if you'd like to get debugging messages, otherwise
// leave the next line alone.
integer debug = FALSE;
 
// Minimum amount of time (in seconds) between sounds.
float min = 10;
 
// Maximum amount of time (in seconds) between sounds.
float max = 30;
 
// This is the volume at which the sound will play.  0 = Inaudible
// Valid values are between 0.0 - 1.0
float vol = 0.5;
 
// Sound to play.
key sound = "dolphin1.wav";
 
default
{
    state_entry()
    {
        if (debug) llSay(0, "Debugging is ON");
 
        // Set the initial timer
        llSetTimerEvent(5.0);
    }
    timer()
    {
        // Play the sound once
        llPlaySound(sound, vol);
 
        // Randomly select the next time (in seconds) to play the sound.
        float time = min + llFrand(max - min);
 
        if (debug) llSay(0, "Time set to" + (string)time);
 
        llSetTimerEvent(time);
    }
}

Animated Shark Head

This object starts to flap it’s jaw and play a laughing sound while worn and while you are typing. Include all these scripts in your object. You will need to add your own “check if typing” script. Easy enough :D

default
{
 state_entry()
 {
 llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SCULPT, "f2151490-db9c-bb10-2048-c423b43aa5d1", PRIM_SCULPT_TYPE_SPHERE]);
 }
 on_rez(integer start_param)
 {
 state default;
 }
 link_message(integer from, integer num, string action, key id)
 {
 if(action == "talk")
 {
 state Toggled;
 }
 }
}
 
state Toggled
{
 state_entry()
 {
 llSetTimerEvent(0.1);
 }
 on_rez(integer start_param)
 {
 state default;
 }
 link_message(integer from, integer num, string action, key id)
 {
 if(action == "stop")
 {
 llSetTimerEvent(0);
 state default;
 }
 }
 timer()
 {
 llMessageLinked(LINK_SET, 0, "anim", NULL_KEY);
 llSetTimerEvent(0.9);
 }
 
}

(more…)

Play sound while typing

default
{
    link_message(integer from, integer num, string action, key id)
    {
        if(action == "anim")
        {
            llLoopSound("25365198-05c6-c97b-c849-e5573fe38d92",1);
        }
        if(action == "stop")
        {
            llStopSound();
        }
    }
}

Sound UUID List

0872f236-fee8-392a-5bb8-7b4485431df1 = Empty
994c82cc-1e48-c565-914d-14e6e3987665 = Jungle, Wildlife
970fe486-4db5-7edf-d384-241266e33f4d = Streaming water, small
4dca3c71-f534-b161-9bf5-dba4bcd9870a = Fireplace ?
5547ec9a-e6d5-1aeb-32f4-dab6213c5daa = Streaming water, medium