Event Driven Sounds

From Second Life Wiki
Revision as of 07:38, 16 July 2012 by Silent Mole (talk | contribs) (Created page with "== Event Driven Sounds == === Touched === Would you like your creation to make noise when someone clicks on it? <lsl> default { touch_start(integer total_number) { …")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Event Driven Sounds

Touched

Would you like your creation to make noise when someone clicks on it?

<lsl> default {

   touch_start(integer total_number)
   {
       llPlaySound( llGetInventoryName( INVENTORY_SOUND, 0 ), 1.0 );
   }

} </lsl>

Near

If someone is nearby, this script will play a sound.

<lsl> float DISTANCE = 3.0; // in meters. float SECONDS = 1.0; // how often to check

default {

   state_entry()   { llSetTimerEvent( SECONDS ); }
   
   sensor( integer n )
   {
       llPlaySound( llGetInventoryName( INVENTORY_SOUND, 0 ), 1.0 );
       llSetTimerEvent( SECONDS );
   }
   
   no_sensor()     { llSetTimerEvent( SECONDS ); }
   
   timer()
   {
       llSetTimerEvent( 0 );
       llSensor( "", NULL_KEY, AGENT, DISTANCE, PI );
   }

} </lsl>

Collided

Sat on