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
Music Jukebox_Track_WAV  

Jukebox_Track_WAV

Jukebox Track WAV.lsl

Category: Music
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Jukebox_Track_WAV
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Jukebox_Track_WAV_1.lsl
1
2 float INTERVAL = 10.00;
3
4 integer LISTEN_CHAN = 2000;
5 integer SEND_CHAN = 2001;
6 float VOLUME = 1.0;
7
8 integer g_iSound;
9 integer tottrack;
10 integer g_iListenCtrl = -1;
11 integer g_iPlaying;
12 integer g_iLinked;
13 integer g_iStop;
14 integer g_iPod;
15 string g_sLink;
16
17 // DEBUG
18 integer g_iWasLinked;
19 integer g_iFinished;
20
21 Initialize()
22 {
23 llSetText(llGetObjectName(), <0, 100, 100>, 10);
24
25 // reset listeners
26 if( g_iListenCtrl != -1 )
27 {
28 llListenRemove(g_iListenCtrl);
29 }
30 g_iListenCtrl = llListen(LISTEN_CHAN,"","","");
31 g_iPlaying = 0;
32 g_iLinked = 0;
33 }
34
35
36
37 PlaySong()
38 {
39 integer i;
40
41 g_iPlaying = 1;
42 llWhisper(0,"Playing...");
47 llSetTimerEvent(5.0); // wait 5 seconds before queueing the second file
48 g_iSound = 1;
49 // for ( i = 1; i < tottrack; i++ )
50 // {
52 // }
53 }
54
55
56 StopSong()
57 {
58 g_iPlaying = 0;
59 llWhisper(0,"Stopping...");
61 llSetTimerEvent(0.0);
62 }
63
64
65 integer CheckLink()
66 {
67 string sLink;
68
69 sLink = llGetLinkName(1);
70 g_sLink = sLink;
71 if( llGetSubString(sLink,0,6) == "Jukebox" )
72 {
73 return TRUE;
74 }
75 return FALSE;
76 }
77
78
79 default
80 {
82 {
83 Initialize();
84 }
85
86 on_rez(integer start_param)
87 {
88 Initialize();
89 if( start_param )
90 {
91 g_iPod = start_param - 1;
92 if( g_iPod )
93 {
95 } else {
96 // Tell the controller what the CD key is so it can link
97 llWhisper(SEND_CHAN,"LINK " + (string)llGetKey());
98 }
99 }
100 }
101
102 changed(integer change)
103 {
104 if( change == CHANGED_LINK )
105 {
106 if( llGetLinkNumber() == 0 )
107 {
108 StopSong();
109 llDie();
110 } else {
111 if( g_iStop )
112 {
113 llMessageLinked(1,llGetLinkNumber(),"UNLINK","");
114 } else {
115 llMessageLinked(1,llGetLinkNumber(),"LINKID","");
116 g_iWasLinked = 1;
117 }
118 }
119 }
120 }
121
122 attach(key id)
123 {
124 if( id == NULL_KEY )
125 {
126 llDie();
127 } else {
128 PlaySong();
129 }
130 }
131
133 {
134 if( perm == PERMISSION_ATTACH )
135 {
137 llSetTexture("clear",ALL_SIDES);
138 }
139 }
140
141 touch_start(integer total_number)
142 {
143 integer i;
144
145 for ( i = 0; i < total_number; i++ )
146 {
147 if( llDetectedKey(i) == llGetOwner() )
148 {
149 llWhisper(0,"DEBUG: g_iPlaying=" + (string)g_iPlaying);
150 llWhisper(0,"DEBUG: Link=" + (string)llGetLinkNumber());
151 llWhisper(0,"DEBUG: g_iWasLinked=" + (string)g_iWasLinked);
152 llWhisper(0,"DEBUG: g_iFinished=" + (string)g_iFinished);
153 if( g_iPlaying )
154 {
155 llWhisper(0,"Stopping...");
156 g_iPlaying = 0;
158 llSetTimerEvent(0.0);
159 } else {
160 PlaySong();
161 }
162 }
163 }
164 }
165
166 listen(integer channel, string name, key id, string message)
167 {
168 if( message == "RESET" )
169 {
170 if( llGetLinkNumber() == 0 )
171 {
172 llDie();
173 } else {
174 llMessageLinked(1,llGetLinkNumber(),"UNLINK","");
175 }
176 }
177
178 if( message == "STOP" )
179 {
180 if( g_iPod )
181 {
182 StopSong();
184 }
185 }
186 }
187
188 link_message(integer sender_num, integer num, string str, key id)
189 {
190 if( str == "PLAY" )
191 {
192 if( !g_iPlaying )
193 {
194 PlaySong();
195 }
196 return;
197 }
198
199 if( str == "STOP" )
200 {
201 g_iStop = 1;
202 StopSong();
203 llMessageLinked(1,llGetLinkNumber(),"UNLINK","");
204 }
205
206 if( str == "VOLUME" )
207 {
208 VOLUME = (float)num / 10.0;
209 llAdjustSoundVolume(VOLUME);
210 }
211 }
212
213 timer()
214 {
215 if( g_iPlaying )
216 {
217 if( g_iSound == 1 )
218 {
219 llSetTimerEvent(INTERVAL);
220 }
222 if( g_iSound < (tottrack - 1) )
223 {
225 }
226 g_iSound++;
227 if( g_iSound >= tottrack )
228 {
229 llSetTimerEvent(INTERVAL + 5.0);
230 g_iPlaying = 0;
231 }
232 } else {
233 if( llGetLinkNumber() != 0 )
234 {
235 llSetTimerEvent(0.0);
236 if( g_iPod )
237 {
238 llWhisper(SEND_CHAN,"FINISH");
240 } else {
241 llMessageLinked(1,0,"FINISH","");
242 g_iFinished = 1;
243 }
244 }
245 }
246 }
247 }
248 // END //

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