Difference between revisions of "Animation triggered sound loop"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with '{{LSL Header}} ====Animation triggered sound loop==== --BETLOG Hax UTC+10: 20091011 1615 [SLT: 20091010 2315] You want a specific animation (thats already ha...')
 
m
Line 22: Line 22:
// Or:
// Or:
//    -Link to the wiki URL from which you copied this script.
//    -Link to the wiki URL from which you copied this script.
//        https://wiki.secondlife.com/wiki/Typing_linkset_alpha_toggle
//        https://wiki.secondlife.com/wiki/Animation_triggered_sound_loop
//    -Document: "Uses parts of <scriptname> by BETLOG Hax"
//    -Document: "Uses parts of <scriptname> by BETLOG Hax"
//        **** LICENCE END ****
//        **** LICENCE END ****

Revision as of 22:18, 10 October 2009

Animation triggered sound loop

--BETLOG Hax UTC+10: 20091011 1615 [SLT: 20091010 2315]

You want a specific animation (thats already handled by your AO) to play a special sound.
This script does the sound bit.
<lsl> //============================================================== // BETLOG Hax // UTC+10: 20091011 1601 [SLT: 20091010 2301] // For Eln Alter //---------------------------------- // **** LICENCE START **** // http://creativecommons.org/licenses/by-sa/3.0/ // Attribution licence: // You must: // -Include this unaltered licence information. // -Supply my original script with your modified version. // -Retain the original scripts' SL permissions. [+c/+m/+t] // Or: // -Link to the wiki URL from which you copied this script. // https://wiki.secondlife.com/wiki/Animation_triggered_sound_loop // -Document: "Uses parts of <scriptname> by BETLOG Hax" // **** LICENCE END **** //============================================================== string gAnimUUID = "";//***THIS HAS TO BE INSERTED BY YOU*** string gSound = "";//having a sound in contents will override //---------------------------------- integer gAnimState; //---------------------------------- f_toggle(integer on) { if(on)

   {   string n = llGetInventoryName(INVENTORY_SOUND,0);
       if(n!="")
           gSound=n;
       if(gSound!="")
           llLoopSound(gSound,1.0);
       else
           llOwnerSay("ERROR: No sound defined in script and none in object contents.
               Without one or the other I cant work.");
   }
   else
       llStopSound();

} //---------------------------------- f_perms() //make it still operate when entering no script areas { if(llGetAttached())

       llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);

} //============================================================== default { state_entry()

   {   if(llGetAttached())//DEV
           f_perms();
       else
           llOwnerSay("You must be wearing me for this to operate.");
   }
   attach(key id) 
   {   f_perms();
   }
   run_time_permissions(integer perm) 
   {   if(perm & PERMISSION_TAKE_CONTROLS)
       {   f_toggle(gAnimState=FALSE);
           llSetTimerEvent(0.444444);
       }
   }
   control(key id, integer pressed, integer change) 
   {   //make it still operate when entering no script areas
   }
   timer() 
   {   if(-1<llListFindList(llGetAnimationList(llGetOwner()), [(key)gAnimUUID]))
       {   if(!gAnimState)
               f_toggle(gAnimState=TRUE);
       }
       else if(gAnimState)
           f_toggle(gAnimState=FALSE);
   }

} //============================================================== </lsl>