Play Sound Menu

Expired

Drop this script and up to 22 sounds into a prim. Users select sound by touch menu and sound plays. Can adjust sound volume. 

 

//Drop this script into an object with up to 22 sound files inside.

//When anyone Touches they will get a menu with all the sounds available. Button names in menu will be first 10 characters from that item's name. 

//NOTE: Sound Names may not exceed 25 characters or script error and menu fails.


float volume = 1.0; //1.0 is full volume, .5 is half volume, etc.

list sound_list;
list sound_list2;
key user = NULL_KEY;

composelist()
{
    integer currentsound = 0;
    integer totalsounds = llGetInventoryNumber(INVENTORY_SOUND);
    
    if(totalsounds > 0 & totalsounds <= 12)
    {
        sound_list = [];
        do
        {
            sound_list = sound_list + llGetInventoryName(INVENTORY_SOUND, currentsound);
            currentsound++;
        }
        while (currentsound > 0 & currentsound  12 & totalsounds <= 22)
    {
        sound_list = ["Next Page"];
        do
        {
            sound_list = sound_list + llGetInventoryName(INVENTORY_SOUND, currentsound);
            currentsound++;
        }
        while (currentsound > 0 & currentsound <11);
        
        sound_list2 = ["Last Page"];
        do
        {
            sound_list2 = sound_list2 + llGetInventoryName(INVENTORY_SOUND, currentsound);
            currentsound++;
        }
        while (currentsound >= 11 & currentsound  22)
    {
        llWhisper(0, "You may only have a maximimum of 22 Sounds. Please remove any extra ones.");
    }
    if(totalsounds == 0)
    {
        llWhisper(0, "Please add up to 22 Sounds.");
    }
}


//The Menu
integer menu_handler;
integer menu_channel;
menu(key user,string title,list sound_list)
{
    menu_channel = (integer)(llFrand(99999.0) * -1); //random channel
    menu_handler = llListen(menu_channel,"","","");
    llDialog(user,title,sound_list,menu_channel);
    llSetTimerEvent(30.0); //menu channel open for 30 seconds
}

default
{
    state_entry()
    {
        composelist(); //make list from inventory sounds
    }

    touch_start(integer total_number)
    {
        user = llDetectedKey(0);
        menu(user,"\n\nPlease select one below.",sound_list);
    }
    
    listen(integer channel,string name,key id,string message)
    {
        if (channel == menu_channel)
        {
            llSetTimerEvent(0.0);
            llListenRemove(menu_handler);
            if(message == "Next Page")
            {
                menu(user,"\n\nPlease select one below.",sound_list2);
            }
            else if(message == "Last Page")
            {
                menu(user,"\n\nPlease select one below.",sound_list);
            }
            else
            {
                llPlaySound(message, volume);
            }
        }
    }
    
    timer() //Close the Menu Listen or we'll get laggy
    {
        llSetTimerEvent(0.0); 
        llListenRemove(menu_handler);
    }
    
    changed(integer change) 
    {
        if (change & CHANGED_INVENTORY) //inventory has changed
        {
            llSleep(0.5);
            composelist(); //rebuild the list
        }
    }
}

 

Collision Sound

Expired

Will play a sound that is inside prim with script when avatar walks onto object.

 

// Sound must be in the object's inventory or it will not work. 
// First sound in inventory will be used if more than 1

integer delay = 5; //how many seconds to wait after playing sound before it can be triggered again


default
{
    on_rez( integer sparam )
    {
        llResetScript();
    }
    
    state_entry()
    {
        llOwnerSay("This object must not be set to phantom or it will not work.");
    }

    collision_start(integer total_number)
    {
        llPlaySound(llGetInventoryName(INVENTORY_SOUND,0), 1);
        llSleep(delay); //keeps it from playing sound over and over
    }
}

 

Water Collision Sound

Expired

default
{
 state_entry()
 {
 llCollisionSound("fd0060b0-1d6e-2bbc-2813-b84224520189", 1.0);
 }
}

 

Repeating Boombox

Expired

//BoomBox by Mitz
integer counter;
integer soundCount;
integer listener;
list songs;
list NEXT;
 
GetSongNames()
{
   integer i;
   for(i=0;i