Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Sound Play_Sound  

Play_Sound

Simple sound script.

Category: Sound
By : Scot Titian
Created: 2010-10-21 Edited: 2010-10-21
Worlds: Second Life

the Zip file

Download all files for Play_Sound
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Play_Sound_1.lsl
1 /*//--Written by Scot Titian--//*/
2 /*// This script is free to //*/
3 /*// use and distribute as //*/
4 /*// long as you leave this //*/
5 /*// headear here at the top //*/
6 /*// of the script. //*/
7 /*//--------------------------//*/
8
9 //--NOTE: To use the name of the Sound you must put the sound in the same object this script is in
10
11 integer gPlaying; //--If we are playing sound
12 key gAnimKey = ""; //--The ID of the sound to play
13 string gAnimName = ""; //--The name of the animation if you don't have the ID
14 integer gUseKey = TRUE; //--Set to false if you don't have the ID of the animation
15 integer gDelay = 20; //--How long to wait before we can play the sound again (In seconds)
16 integer gCanPlay; //--If the animation can play (for the delay)
17 integer gAllowAll = TRUE; //--If everyone can click us (Set to false for owner only)
18
19 default
20 {
22 {
23 gPlaying = FALSE; //--We start out not playing sound
24 gCanPlay = TRUE; //--We start able to play
25 }
26
27 touch_start(integer total_number)
28 {
29 if(TRUE == gAllowAll)
30 {
31 if(TRUE == gCanPlay)
32 {
33 if(TRUE == gUseKey) //--Play the sound using it's key
34 llPlaySound(gAnimKey,1);
35
36 else if(FALSE == gUseKey) //--Play the sound using it's name
37 llPlaySound(gAnimName,1);
38 gCanPlay = FALSE;
39 llSetTimerEvent(gDelay);
40 }
41 }
42 else if(FALSE == gAllowAll)
43 {
44 key vKey = llDetectedKey(0);
45
46 if(TRUE == gCanPlay && llGetOwner() == vKey)
47 {
48 if(TRUE == gUseKey) //--Play the sound using it's key
49 llPlaySound(gAnimKey,1);
50
51 else if(FALSE == gUseKey) //--Play the sound using it's name
52 llPlaySound(gAnimName,1);
53 gCanPlay = FALSE;
54 llSetTimerEvent(gDelay);
55 }
56 }
57 }
58 timer()
59 {
61 gCanPlay = TRUE;
62 }
63 }

Back to the Best Free Tools in Second Life and OpenSim.