I've got a script for a dancer, but I'm not sure how to get it to loop back to the beginning once it plays the last sound. Can anyone help? string ANIMATION = "hold"; // put here name of your animation
float SOUND_LENGTH = 9.12; // put here length of your sound
float SOUND_VOLUME = 1.0; // puth here volume (1.0 = max )
integer numNames = 0;
integer playing = FALSE;
integer actNum = 0;
playSound( integer stat )
{
if ( stat == TRUE ){
actNum = 0;
llPreloadSound( llGetInventoryName( INVENTORY_SOUND, actNum ) );
playing = TRUE;
llSetTimerEvent( 1.0 );
if ( ANIMATION != "" ) {
llSleep( 1.0 );
llStartAnimation( ANIMATION );
}
}
else {
playing = FALSE;
llStopSound();
llSetTimerEvent( 0.0 );
if ( ANIMATION != "" ) {
llStopAnimation( ANIMATION );
}
}
} // End playSound( integer stat )
// ------------------------------------------------------------
// ------------------------------------------------------------
default
{
on_rez( integer num )
{
llResetScript();
}
state_entry()
{
llRequestPermissions( llGetOwner(), PERMISSION_TRIGGER_ANIMATION );
} // End state_entry()
run_time_permissions(integer perm)
{
if ( perm & PERMISSION_TRIGGER_ANIMATION ) {
numNames = llGetInventoryNumber( INVENTORY_SOUND );
if ( numNames > 0 ){
llOwnerSay(" Commands 'smangon' or 'smangoff'");
llListen( PUBLIC_CHANNEL, "", "", "" );
}
else {
llOwnerSay( "Any sound in the inventory!" );
}
}
else {
llRequestPermissions( llGetOwner(), PERMISSION_TRIGGER_ANIMATION );
}
} // End run_time_permissions(integer perm)
attach(key attached)
{
if ( attached != NULL_KEY ){
llResetScript();
}
} // End attach(key attached)
listen(integer channel, string name, key id, string message)
{
message = llToLower( message );
if( ( message == "smangon" ) && ( playing == FALSE ) ) {
playSound( TRUE );
}
else if( ( message == "smangoff" ) && ( playing == TRUE ) ) {
playSound( FALSE );
}
} // End listen(integer channel, string name, key id, string message)
timer()
{
if ( playing == TRUE ) {
llSetTimerEvent( SOUND_LENGTH );
if ( actNum == numNames ) {
actNum = 0;
llSetTimerEvent( 0.2 );
}
else {
if ( actNum>0) {
llStopSound();
}
llPlaySound( llGetInventoryName( INVENTORY_SOUND, actNum ), SOUND_VOLUME );
++actNum;
if ( actNum < (numNames - 1))
{
llPreloadSound( llGetInventoryName( INVENTORY_SOUND, actNum ) );
}
if ( actNum == numNames)
{
playing = FALSE;
llSleep( 1.5 );
llStopAnimation( ANIMATION );
}
}
}
else
{
actNum = 0;
llStopSound();
if ( ANIMATION != "" )
{
llStopAnimation( ANIMATION );
}
llSetTimerEvent( 0.0 );
}
} // End timer()
} // End state default
// ------------------------------------------------------------
// ------------------------------------------------------------