|
Dick Spad
Life is a Pose Ball ....
Join date: 29 Oct 2007
Posts: 205
|
11-23-2008 13:46
I wrote a little script for a friend to play a sound and repeats it every 30 seconds once an avatar is with in 1 meter, which works great… but really would like it to play more then one sound that’s in the inventory .. sort of like cycle though them…. But not sure which statement I would use to get this to work. Any help would be most appreciate. Here’s the script I’m using …
default {
state_entry() { llSensorRepeat("", NULL_KEY, AGENT, 1, PI, 5); llSetTimerEvent(30); } sensor(integer total_number) { } timer() {
llPlaySound(llGetInventoryName(INVENTORY_ALL,0),1);
}
}
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
11-23-2008 14:29
For free: // Play inventory sounds, Studio Dora, Dora Gustafson 2008 // free for anybody to take, use, modify and flush // Play when some agent is within sensor reach // Next song after 'Tplay' seconds // v1.1 tuned for better timing // will reset on inventory change
list sounds; integer nos; integer song; float Tscan=5.0; // scan interval in no play float Tplay=30.0; // scan interval in play float senseR=1.0; // sensor reach
play_song() { song = ++song % nos; llPlaySound( llList2String( sounds, song ), 1.0 ); }
default { state_entry() { sounds = []; nos = llGetInventoryNumber(INVENTORY_SOUND); integer x = nos; while (--x >= 0) { string name = llGetInventoryName(INVENTORY_SOUND, x); sounds = (sounds = []) + sounds + [name]; } if ( nos ) state no_play; else llOwnerSay( "No sounds in object inventory" ); } }
state play { state_entry() { llSensorRepeat("", NULL_KEY, AGENT, senseR, PI, Tplay); play_song(); } sensor(integer num_detected) { play_song(); } no_sensor() { state no_play; } changed(integer change) { if ( change & CHANGED_INVENTORY ) llResetScript(); } }
state no_play { state_entry() { llSensorRepeat("", NULL_KEY, AGENT, senseR, PI, Tscan); } sensor(integer num_detected) { state play; } changed(integer change) { if ( change & CHANGED_INVENTORY ) llResetScript(); } }
may do what you want  EDIT: Script modified to make it fulfill time specifications and to tune it
_____________________
From Studio Dora
|
|
Dick Spad
Life is a Pose Ball ....
Join date: 29 Oct 2007
Posts: 205
|
11-23-2008 15:32
Thanks very much Dora!!! that's awesome .....
|