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.

Search This Blog

Complexity Rating

About Me

Chey is having a fabulous second life, thank you very much. She is owner of Flights of Fancy Creations, where you can find things you want and things you need. She can usually be found with her over-the-top partner Sweetie on their sim Whimsy, a tropical archipelago with an active volcano and a kickass steam train-- or perhaps on Whimsy Kaboom at the robot sanatorium, home to the many mentally malfunctioning mechanoids of the Metaverse.

About This Blog

My purpose in this blog is to share what I have learned about scripting in Second Life and provide you with free full-permission scripts to use as you wish. I ask only that you not charge others for them unless you significantly modify them. By significantly I mean you add functionality to the script-- not just change variables or chat messages.

Much of the work will be mine. Some of it is in the public domain. When that is so and when I know the author, I will acknowledge the author(s) in text and in the code of the scirpt.

Some scripts will be simple, some more complex. I hope that whatever you need, you will find something useful here.