Advertisement
QuantumDoge

LSL Proximity Loop (1 sound)

May 9th, 2024 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Linden Scripting 1.13 KB | Source Code | 0 0
  1. // Constants
  2. string SOUND_UUID = "77eee9a2-edc7-dd16-8dd6-25ec286c1a00";
  3. float DETECTION_RANGE = 1.5; // in meters
  4.  
  5. // Declare variables
  6. integer soundHandle;
  7.  
  8.     detached(key detached)
  9.     {
  10.         // Make sure the script only runs when detached from an avatar
  11.         if (detached == llGetOwner())
  12.         {
  13.             // Hide the object when detached
  14.             llSetAlpha(0.0, ALL_SIDES);
  15.         }
  16. }    
  17.  
  18. default
  19. {
  20.     state_entry()
  21.     {
  22.         // Start the looping sound when the object is attached
  23.         llLoopSound(SOUND_UUID, 0.2); // Loop the sound with a volume of 1.0
  24.         llSetSoundQueueing(TRUE); // Allow the sound to play even if not heard
  25.         llSetSoundRadius(DETECTION_RANGE); // Set the sound radius for detection
  26.  
  27.         // Hide the object by making it transparent when attached
  28.         llSetAlpha(0.0, ALL_SIDES);
  29.     }
  30.  
  31.     attach(key attached)
  32.     {
  33.         // Make sure the script only runs when attached to an avatar
  34.         if (attached == llGetOwner())
  35.         {
  36.             // Show the object again when attached
  37.             llSetAlpha(1.0, ALL_SIDES);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement