Sound Ambiator  
This script randomly plays the sounds you list for it.  You can use different lists for day or night.  To import your own sounds, see:
Audacity  101
Tools for getting a list of sounds (or other classes) in the contents of an object: Tools
   
Sound Ambiator.  Randomly plays a list of sounds provided in the script.  Can play one list for day and another list for night.  
list GdaySounds = ["Alleycat", "surf","Crow", "seagull2","docksl","boathornAU"];
list GnightSounds = [ "heysl", "coyotesl", "dogfar","sltrainwh1","docksl", "dogfar", "boathornAU","painmoanA","Great Horned Owl","surf"];
integer Grand = 10 ;
Global variables.    To add a sound, put the sound file in the contents of object and add the name to the list. Spelling and capitals count.
default {
   state_entry()
 

{ llStopSound();
llSetTimerEvent(5.0); }

Set timer event to 5 seconds

 

timer()

 

{vector time = llGetSunDirection();
string soundname;
Grand = Grand+1;
llSetTimerEvent(10+ llFrand(18.0));

Get sun direction

Random number

Reset timer

if(Grand>12)
{GdaySounds = llListRandomize(GdaySounds, 1);
GnightSounds = llListRandomize(GnightSounds, 1);
Grand = 0; }

Randomize list every 12 passes.

if (time.z > 0.0)
{soundname = llList2String (GdaySounds, 0);
GdaySounds = GdaySounds + (list) soundname ;
GdaySounds = llDeleteSubList(GdaySounds, 0, 0);}

else
{soundname = llList2String (GnightSounds, 0);
GnightSounds = GnightSounds + (list) soundname ;
GnightSounds = llDeleteSubList(GnightSounds, 0, 0);}

If clause to test for day or night

Manipulate strings

 

 llTriggerSoundLimited(soundname, 1.0, llGetPos() + <12,12,12>, llGetPos() - <12,12,12>);

Trigger sounds
   }
}
close timer block
close Default
   
The Thinkerer 05/09/2008
Copyright (c) D. F. Dansereau & S. H. Evans

Site Map

Where start?

LODScr
Famous fables