Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

sounds in object

Grizzly Ogg
Registered User
Join date: 10 May 2006
Posts: 39
06-05-2006 16:00
Hi again how to makes Sounds in a Object. Like if you Click on it the sound will start click on it again it will stop i have tryed many scripts but they dont work dont know why.
My sounds name is Code 3 its to a fire alarm
Say the script Plz
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
06-06-2006 01:28
CODE
integer playing = FALSE;
default {
touch_start(integer x) {
if (playing) llStopSound();
else llPlaySound("Code 3", 1.0);
playing = !playing; // toggle playing
}
}


If the sound is not in the inventory of the object, then instead of "Code 3" you will want to right-click the sound in YOUR inventory and choose "Copy asset UUID" and paste that in instead with quotation marks around it.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
06-06-2006 02:14
If you want the sound to loop continuously, which it sounds like you do, you need to change one line thus:

CODE

integer playing = FALSE;
default {
touch_start(integer x) {
if (playing) llStopSound();
else llLoopSound("Code 3", 1.0);
playing = !playing; // toggle playing
}
}
Grizzly Ogg
Registered User
Join date: 10 May 2006
Posts: 39
06-06-2006 02:28
Yes its works Thx guys :D
RaveWolf Strauss
Registered User
Join date: 1 Jan 2006
Posts: 53
lol This Helped ME Out Also But...
06-06-2006 06:32
Was Going To Look For a script similiar to what grizzly asked but im using it at night so is there a way to have crickets sound and like a owl and wolf sound all using jus one prim or do i have to use seperate prims for each sound And Of Course I wouldnt Want The Owls Loopin As That could Get Annoying lol maybe time delayed for each sound to play pls help and ty in advance
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
06-06-2006 08:09
Each prim can only play one sound at a time.

If you wanted continuous crickets you could do that with a suitably looped sound similar to the script I posted. You'd want a timer to turn it on and off though... if you search this forum there are a fair number of recent threads including scripts about ways to detect night and day.

For the occasional owl, you'd need another prim. A random timer during the night would probably work most nicely. A different timer system could work well there, detect if it's day and if it is set the timer to 3 hours (10800 seconds) so it will start again sometime after dark... then a shorter random period, say llFrand(600.0) if you want it to play roughly every 5 minutes - that will actually be evenly distributed between 0 and 10 minutes.
RaveWolf Strauss
Registered User
Join date: 1 Jan 2006
Posts: 53
ok
06-06-2006 08:14
Tyvm For Your Help This Has Helped Me a Great Deal
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
06-06-2006 09:34
From: Eloise Pasteur
A different timer system could work well there, detect if it's day and if it is set the timer to 3 hours (10800 seconds) so it will start again sometime after dark...


You could also use llGetSunDirection to determine the height of the sun (Z value). Use that to determine if it is day or night. Use a timer that fires at some long interval (like 10-15 minutes) to check if the sun is down (using llGetSunDirection) and then start the cricket sounds.

This approach is a more reliable way of figuring out if it is night/day (for me anyways).

-2fast
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
06-06-2006 12:13
I agree for specifically timed things, like the continuous nightsong - that method is the one that's used in all the other posts on this forum about detecting night and day, and the one I use for my time critical things too. Rather than reproducing all the code I figured sending the OP to use search was ok.

But for the specific thing of the owls he doesn't need or want a precise time, he want's a hoot every now and again during the night. Not starting precisely at dusk is therefore, probably, perfectly acceptable to the purpose.
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
06-06-2006 12:47
From: Eloise Pasteur
...therefore, probably, perfectly acceptable to the purpose.


Oh I agree - just my L$6 (about $0.02 :) )

-2fast
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
06-06-2006 13:41
You don't really need more than one prim to do owls and wolves, so long as you didn't mind stopping the crickets for a moment to play the owl hoot or wolf howl? I have a script in my "dishwasher" in my house's kitchen, when it comes on it starts playing a dishwasher noise, then randomly stops it, plays one of several crashing dish noises then continues playing the running noise again (it's an evil dishwasher, all appliances in my kitchen are evil, except the fridge which gives you ice cream ^_^).

Would that suffice?

Oh and, eep, yeah I put the wrong function for playing the sound, my bad, sorry!
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)