Jump to content

Babywolfpup

Resident
  • Content Count

    2
  • Joined

  • Last visited

Posts posted by Babywolfpup


  1. I Have been trying to Modify a few Full song Music Player Scripts to play 15-20 Songs useing a Menu with Multiple pages and have failed Horably. Can anyone Provide a Script like this or is it not possible? if it is Possible with a HUD type system that will also work, but i have tried everthing and had no luck. I have tried Combineing this one script with another that might work but i do not know enough about scripting to make it work.  

    First Script/ Main Script

    // V2 //

    // This list is all you need to edit. List the names of the songs (each collection of sound files that makes one song)
    // followed by the length of those sound clips (each song should contain clips of equal length)

    // The list should be structured like so -

    // list songs = ["First Song", 9.0, "Second Song", 9.65, "Third Song", 9.45];

    // The names of the songs must be identical to some part of the sound files used for that song like so -

    //// In the prim inventory (along with this script) -

    ////// Box_Of_Rain_wav_1
    ////// Box_Of_Rain_wav_2
    ////// Box_Of_Rain_wav_3
    ////// Servant 1
    ////// Servant 2
    ////// Servant 3

    //// In the script -

    ////// list songs = ["Box_Of_Rain", 9.2, "Servant", 9.8];

    // The script will play the clips in alpha/numerical order so name them wisely.

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////ONLY EDIT BELOW HERE///////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    list songs = ["Box_Of_Rain", 9.2, "Servant", 9.8]; // YUP! EDIT THIS BIT ;-)

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////ONLY EDIT ABOVE HERE///////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    integer volume = 10;

    integer lis_count;

    integer playing;

    integer busy;

    integer part;

    integer lis;

    integer sl;

    float delay;

    list cancel = ["CANCEL"];

    list playlist;

    list waiting;

    list song;

    list NEXT;

    string vol_str = "Volume";

    string song_str = "Songs";

    string song_name;

    list StrideOfList(list src, integer stride, integer start, integer end)

    {
    list l = [];
    integer ll = llGetListLength(src);
    if(start < 0)start += ll;
    if(end < 0)end += ll;
    if(end < start) return llList2List(src, start, start);
    while(start <= end)
    {
    l += llList2List(src, start, start);
    start += stride;
    }
    return l;
    }

    list Volumes(integer vol)
    {
    integer v = 0;
    list l = [];
    do
    {
    if(v != vol)
    l += [((string)v)];
    }
    while((++v) <= 10);
    return l;
    }
    SetListenTimer(playing);
    if(msg == vol_str)
    {
    llDialog(id, "\nChange the volume?\nThe current volume is set at \"" + ((string)volume) + "\"", cancel + Volumes(volume), chan);
    return;
    }
    if(msg == song_str)
    {
    string current = "";
    if(playlist)
    {
    current = "\n\nThe songs currently queued are\n\"" + llList2String(playlist, 0) + "\" (currently playing)";
    if(llGetListLength(playlist) > 1)
    current += "\n\"" + llDumpList2String(llList2List(playlist, 1, -1), "\"\n\"") + "\"";
    }
    llDialog(id, llGetSubString(("\nSelect a song to play?" + current), 0, 500), cancel + StrideOfList(songs, 2, 0, -1), chan);
    return;
    }
    if(llListFindList(Volumes(volume), [msg]) != -1)
    {
    llAdjustSoundVolume(ScaleVol((volume = ((integer)msg))));
    PageOne(id, chan);
    return;
    }
    if(llGetListLength((playlist += [msg])) == 1)
    PlaySong((song_name = msg));
    }
    if(CheckWaitingRoom(chan))
    return;
    RemoveListen(1);
    }
    timer()
    {
    if(playlist)
    {
    if(!playing)
    {
    llSetTimerEvent(delay);
    playing = TRUE;
    }
    llPlaySound(llList2String(song, part), ScaleVol(volume));
    if((++part) == sl)
    {
    if(llGetListLength(playlist) > 1)
    {
    song_name = llList2String((playlist = llDeleteSubList(playlist, 0, 0)), 0);
    llSleep(delay);
    PlaySong(song_name);
    }
    else
    {
    llSetTimerEvent(0.0);
    song_name = "";
    playing = FALSE;
    playlist = [];
    }
    }
    else if(part == (sl - 1))
    llPreloadSound(llList2String(song, 0));
    else
    llPreloadSound(llList2String(song, (part + 1)));
    }
    if(lis && (!(--lis_count)))
    {
    if(!(CheckWaitingRoom(0)))
    RemoveListen(1);
    }
    // IMPORTANT = HOW LONG you have sliced your wav files into pieces
    float timer_interval = 9.0; // time interval between requesting server to play the next 10 second wave

    float set_text_alpha = 1; // the text transparency fo alpha text. Set this to 0 to disable hovertext
    integer debugflag = FALSE; // chat debug info to owner if TRUE

    // Stuff that you should not mess with:

    integer preloadchannel ;
    integer playchannel ;

    integer running = TRUE; // flag to say we are on
    vector set_text_colour = <1,1,1>; // colour of floating text label ( white)

    // times just below 10 seconds are suitable as we use sound queueing
    integer total_wave_files; // number of wave files
    integer i_playcounter; // used by timer() player


    DEBUG (string msg)
    {
    if (debugflag) llOwnerSay(msg);
    }


    go(integer play) {

    if (play)
    {
    Preload();
    llSetTimerEvent(timer_interval);
    running = TRUE;
    } else {
    running = FALSE;
    llSetTimerEvent(0.0);
    llStopSound();
    DEBUG("Stopped");
    llSetText(llGetObjectName() + "\n"
    + (string) preloadchannel
    + "\n"
    + "Stopped", <0,1,0>, set_text_alpha);
    }
    }


    Preload()
    {
    string preloading_wave_name = llGetInventoryName(INVENTORY_SOUND, i_playcounter);

    llRegionSay(preloadchannel,preloading_wave_name); // tell slaves to preload a file
    DEBUG("Preloading wav: " + (string)i_playcounter + " " + (string) preloading_wave_name);
    llSetTimerEvent(2.0);

    // start playing
    }

    Loadnext()
    {

    i_playcounter ++;
    if (i_playcounter >= total_wave_files)
    i_playcounter = 0;

    integer next = i_playcounter +1;
    if (next > total_wave_files)
    next = 0;

    string preloading_wave_name = llGetInventoryName(INVENTORY_SOUND, i_playcounter);

    llRegionSay(preloadchannel,preloading_wave_name); // tell slaves to preload a file
    DEBUG("Preloading wav: " + (string)i_playcounter + " " + (string) preloading_wave_name);
    llSetTimerEvent(timer_interval);
    }

    default
    {
    state_entry()
    {
    total_wave_files = llGetInventoryNumber(INVENTORY_SOUND);

    if (total_wave_files == 0)
    {
    llOwnerSay("Add 9 second wav files to the prim and reset it");
    return;
    }
    llSetSoundQueueing(TRUE); // only works on llPlaySound not llTriggerSound, so we can queue these silently
    preloadchannel = (integer) llGetObjectDesc();
    if (preloadchannel == 0) {
    preloadchannel = llCeil(llFrand(1000) + 1000);
    llSetObjectDesc((string) preloadchannel);
    }

    playchannel = preloadchannel +1;
    //set text above object to the name of the object and channel
    llSetText(llGetObjectName()
    + "\nChannel: "
    + (string) preloadchannel, <0,1,0>, set_text_alpha);
    go(TRUE);

    }

    touch_start(integer total_number)
    {
    if (!running)
    go(TRUE);
    else
    go(FALSE);
    }

    timer()
    {
    string playing_wave_name = llGetInventoryName(INVENTORY_SOUND, i_playcounter);
    DEBUG("llPlaySound wav: " + (string)i_playcounter + " " + playing_wave_name );
    llPlaySound(playing_wave_name,1.0);
    llRegionSay(playchannel,playing_wave_name); // tell slaves to play a file

    llSetText(llGetObjectName() + "\n"
    + playing_wave_name + "\n"
    +"Playing " + (string)(i_playcounter +1)
    + " of " + (string)(total_wave_files) , set_text_colour, set_text_alpha);

    DEBUG("Playing wav:"
    + (string)(i_playcounter )
    + ":"
    + (string) playing_wave_name);


    Loadnext();
    }

    link_message(integer sender_number, integer number, string message, key id)
    {
    if (message == "play")
    {
    go(TRUE);
    }
    else if (message == "stop")
    {
    go(FALSE);
    }
    }
    }

     

    Combineing the one above with this script:

     

    //start_unprocessed_text
    /*/|/ :CATEGORY:Sound
    /|/ :NAME:BoomBox
    /|/ :AUTHOR:Mitz
    /|/ :CREATED:2010-01-10 05:20:56.000
    /|/ :EDITED:2013-09-18 15:38:49
    /|/ :ID:111
    /|/ :NUM:152
    /|/ :REV:1.0
    /|/ :WORLD:Second Life
    /|/ :DESCRIPTION:
    /|/ boombox.lsl
    /|/ :CODE:
    /|/BoomBox by Mitz

    list songslist;


    //the actual menu buttons are stored in the buttonslist
    list buttonslist;

    list songs = ["Smile", 9.0, "Giddy Up", 10.0, "Lullaby", 10.0, "Just A Pony", 10.0, "Becomming Popular", 10.0, "Let the Rainbow MLP", 10.0, "A True, True Friend", 10.0, "Winter Wrap Up", 10.0, "Art Of The Dress", 10.0, "Children Of The Night", 10.0, "Cutie Mark Crusaders", 10.0, "Friends Are always There", 10.0]; // YUP! EDIT THIS BIT ;-)

    //some variables.
    //Do not change anything below this line
    //except you know what you are doing ;-)
    //Customer Service: Alice Klinger

    float time=10.0;
    key owner;
    key target;
    key toucher;
    integer current;
    integer count;
    integer choice=0;

    list songs;

    list NEXT;

     

    GetSongNames()

    {

    integer i;

    for(i=0;i < llGetInventoryNumber(INVENTORY_SOUND);i++)

    {

    songs += llGetInventoryName(INVENTORY_SOUND, i);

    }

    }

     

     

    default

     

    {

     

    changed(integer what)

    {

    if (what & CHANGED_INVENTORY)

    llResetScript();

    }

    on_rez(integer rez)

    {

    llResetScript();

    }

     

    state_entry()

    {

    counter =0;

    llStopSound();

    GetSongNames();

    /|/PreLoadSongs();

    soundCount = llGetInventoryNumber(INVENTORY_SOUND);

    llListen(-1, "", llGetOwner(), "");

    NEXT = llList2List(songs, 0, 8);

    }

     

    touch_start(integer fingers)

    {

    if(llDetectedKey(0) == llGetOwner() )

    {

    llDialog(llGetOwner(), "Songs", NEXT + ["< Prev", "Stop", "Next >"], -1);

    }

    }

     

    listen(integer channel, string name, key id, string message)

    {

    if(message != "< Prev" && message != "Stop" && message != "Next >" )

    {

    llLoopSound(message, 1);

    llOwnerSay("Now Playing " + llToUpper(message) );

    }else{

    if(message == "< Prev")

    {

    counter = counter - 9;

    NEXT = [];

    NEXT = llList2List(songs, counter , -1);

    if( llGetListLength(NEXT) > 9)

    {

    NEXT = llDeleteSubList(NEXT, 9, -1);

    }

    llDialog(llGetOwner(), "Songs", NEXT + ["< Prev", "Stop", "Next >"], -1);

    }

     

    if(message == "Stop")

    {

    llStopSound();

    }

     

    if(message == "Next >")

    {

    counter = counter + 9;

    NEXT = [];

    NEXT = llList2List(songs, counter , -1);

    if( llGetListLength(NEXT) > 9)

    {

    NEXT = llDeleteSubList(NEXT, 9, -1);

    }

    llDialog(llGetOwner(), "Songs", NEXT + ["< Prev", "Stop", "Next >"], -1);

    }

    }

    }

     

×
×
  • Create New...