MLPV2 Ambiant Sound Add-on

From Second Life Wiki
Revision as of 13:19, 21 July 2010 by Lear Cale (talk | contribs)
Jump to navigation Jump to search


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 PlaySound | 0,-4,989999,SoundName
LINKMSG StopSound | 0,-4,989999,stoploop


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> // SOUND_SCRIPT //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 llLoopSound(str, 1); // 1 is the volume of the played sound - must be between 0.0 (silent) and 1.0 (loud)
       }
   }

} </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>