Wednesday, October 1, 2014

Simple Timer [Level II]

Timers are essential tools. We need them for a variety of reasons--- to play sounds or make particles at specified intervals, to time out blue menus, to stop prims from listening (and save server resources), or to pace changes in a prim's position or characteristics.

It's possible to use multiple timers (and I will eventually write about this), but for now, here's an annotated script that will play a click sound at a specified interval after the prim has been touched.

//----- Cut the text below and paste it into a script in your prim in Second Life

// Simple Timer by Cheyenne Palisades
//
float interval = 3.5
// a float is a variable; set this one to set your timer's interval in seconds

default
{
    touch_start(integer total_number)
    // do the following when prim is touched
    {
         llPlaySound("bac3e333-9624-4b1a-ade2-d2b01d5960aa", 1);
         // Plays double click sound when prim is touched
         // The numbers in quotes are the UUID of the sound
         // The last number is the volume; you can set it from 0 (silent) to 1 (loudest)
       
        llSetTimerEvent(interval);
        // Now the timer is set to (interval) seconds, 3.5 if you haven't changed the first line of this script
    }
 
timer()
    {
        llPlaySound("bac3e333-9624-4b1a-ade2-d2b01d5960aa", 1);
        // Plays double click every (interval) seconds after prim has been touched. This will continue indefinitely or until timer is set to 0
    }
}

// You can substitute your own sound by replacindg the UUIDs above-- or drop the sound into your prim and replace the UUID with the name of the sound. Sound will fail if UUIS or name is not exact.

// End

No comments:

Post a Comment