Difference between revisions of "MLPV2 Ambiant Sound Add-on"

From Second Life Wiki
Jump to navigation Jump to search
Line 18: Line 18:
#Add to the menu in an MLPV2 menu notecard the following line(s):
#Add to the menu in an MLPV2 menu notecard the following line(s):


LINKMSG PlaySound | 0,-4,989999,SoundName
  LINKMSG PlaySound1 | 0,-4,989999,SoundName
LINKMSG StopSound | 0,-4,989999,stoploop
  LINKMSG PlaySound2 | 0,-4,989999,SoundName2
  LINKMSG StopSound | 0,-4,989999,stoploop
In the above line, there are elements for you to customize as appropriate:


* PlaySound/StopSound : these are the button labels (in the menu)
* SoundName1 and SoundName2 : the name of the sound (in inventory)


 
You can have any number of different sounds.
In the above line, there are two elements for you to customize as appropriate:
 
 
* PlaySound/StopSound : the wording that you want to appear for the button on the blue menu that will play/stop the sound.
* SoundName : the name of the sound you want to be played.
 


<lsl>
<lsl>
// SOUND_SCRIPT  
// SOUND_SCRIPT (MULTIPLE)
//add-on by Teq Hutchinson for MLPV2 by Lear Cale. November 2009.
// add-on by Teq Hutchinson for MLPV2 by Lear Cale. November 2009.
// STOP feature added by Lear Cale


default
default {
{
     link_message(integer sender_num, integer num, string str, key id) {
     link_message(integer sender_num, integer num, string str, key id)  
        if (num == 0 && str == "STOP") {
    {
            llStopSound();
         if (num ==989999)
         } else if (num == 989999) {
        {
            llStopSound();
             if (str == "stoploop") llStopSound();
             if (str != "stoploop") {
            else llLoopSound(str, 1); // 1 is the volume of the played sound - must be between 0.0 (silent) and 1.0 (loud)
                llStopSound();
                llLoopSound(str, .5); // .5 is the volume of the played sound - must be between 0.0 (silent) and 1.0 (loudest)
            }
         }
         }
     }
     }
}
</lsl>
'''If you want to offer multiple choices:'''
LINKMSG PlaySound1 | 0,-4,989999,SoundName1
LINKMSG PlaySound2 | 0,-4,989999,SoundName2
....
LINKMSG StopSound | 0,-4,989999,stoploop
<lsl>
// SOUND_SCRIPT (MULTIPLE)
//add-on by Teq Hutchinson for MLPV2 by Lear Cale. November 2009.
default
{
link_message(integer sender_num, integer num, string str, key id)
{
if (num ==989999)
{
if (str == "stoploop") llStopSound();
else
{
llStopSound();
llLoopSound(str, 1); // 1 is the volume of the played sound - must be between 0.0 (silent) and 1.0 (loud)
}
}
}
}
}
</lsl>
</lsl>

Revision as of 13:28, 21 July 2010


Simple add on tool for MLPV2 that puts a button on the MLPV2 menu that, when clicked, play a looped sound in the content of the prim where the MLPV2 scripts are. (This script won't work for props, only for the prim where the MLPV2 scripts are, and the prims linked to it)

By Teq Hutchinson, November 2009.


Steps to use:

  1. Copy and paste the Sound_Script on this page into a script called as you want;
  2. Drop this script into the prim where you have the rest of the MLPV2 scripts;
  3. Drop the sound you want to be played into the prim where you have the rest of the MLPV2 scripts;
  4. Add to the menu in an MLPV2 menu notecard the following line(s):
 LINKMSG PlaySound1 | 0,-4,989999,SoundName
 LINKMSG PlaySound2 | 0,-4,989999,SoundName2
 LINKMSG StopSound | 0,-4,989999,stoploop

In the above line, there are elements for you to customize as appropriate:

  • PlaySound/StopSound : these are the button labels (in the menu)
  • SoundName1 and SoundName2 : the name of the sound (in inventory)

You can have any number of different sounds.

<lsl> // SOUND_SCRIPT (MULTIPLE) // add-on by Teq Hutchinson for MLPV2 by Lear Cale. November 2009. // STOP feature added by Lear Cale

default {

   link_message(integer sender_num, integer num, string str, key id) {
       if (num == 0 && str == "STOP") {
           llStopSound();
       } else if (num == 989999) {
           llStopSound();
           if (str != "stoploop") {
               llStopSound();
               llLoopSound(str, .5); // .5 is the volume of the played sound - must be between 0.0 (silent) and 1.0 (loudest)
           }
       }
   }

} </lsl>