Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

how to add touch sound to an object

Temperence Dagger
Registered User
Join date: 26 May 2007
Posts: 14
05-29-2007 16:15
Hi.. I am totally new at this. I was wondering how you add a script that would allow an object to be touched and play a sound.

I have looked all over for a script that would do this but cannot find one and I have NO idea how to write scripts.

If anyone could help me I would greatly appreciate it!

Thank you
Dnel DaSilva
Master Xessorizer
Join date: 22 May 2005
Posts: 781
05-29-2007 16:46
Try the proper forums "Scripting Tips" or "Products Wanted". You are much more likely to get a useable response there.
_____________________
Xessories in Urbane, home of high quality jewelry and accessories.

Coming soon to www.xessories.net

Why accessorize when you can Xessorize?
Aleister Montgomery
Minding the gap
Join date: 30 Apr 2006
Posts: 846
05-29-2007 17:25
Right-click the object and select "Edit". Click "More" in the edit window and go to the "Content" tab. Drag a sound file into the object's inventory (the large empty space under "Content";).
Click the button "New Script". Double-click the script file, delete all text and paste this in:

default
{
touch_start(integer total_number)
{
llTriggerSound("soundfile", 1);
}
}

Replace "soundfile" with the name of your audio file (in quotation marks). If the sound should be continuously looped, replace llTriggerSound with llLoopSound. It will then never stop playing though, until the command llStopSound(); is used.
Example (sound looping for 30 seconds):

default
{
touch_start(integer total_number)
{
llLoopSound("soundfile", 1);
llSetTimerEvent(30);
}
timer()
{
llStopSound();
llSetTimerEvent(0);
}
}

Btw, you can upload any .wav sound into SL, as long as the file is recorded with 44.100 kHz, 16 bit. Use the audio recorder that comes with Windows to convert a soundfile to these settings. It can't be too long though, a complete music title won't be possible (aside from the copyright issues).
Storm Thunders
Polyavatarist
Join date: 31 May 2006
Posts: 157
05-30-2007 04:21
Stop by NCI and pick up the Sound Prims package. Or look me up in Search inworld and grab the freebies at my main shop.

One of the Sound Prims will play sound on touch.