Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Object to play random sound when touched.

Yoofaloof Pacer
Registered User
Join date: 12 Apr 2005
Posts: 27
04-28-2006 16:29
Hi there,

I'm after a script which would play a random sound out of 5 say, when an object is touched.

Any help would be appreciated. Ta!
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
04-28-2006 16:46
CODE

default
{
touch_start(integer num)
{
integer n = llGetInventoryNumber(INVENTORY_SOUND);
integer i = llFloor(llFrand(n));
llPlaySound(llGetInventoryName(INVENTORY_SOUND, i), 0.5);
}
}


Haven't tested it, but I think that should randomly play a sound from the sound files in the object's inventory.
Yoofaloof Pacer
Registered User
Join date: 12 Apr 2005
Posts: 27
04-30-2006 04:57
Thanks, but it doesn't work. No sounds play.
SteveR Whiplash
teh Monkeh
Join date: 24 Sep 2004
Posts: 173
04-30-2006 06:06
Works fine for me. You did put sounds in the object for the script to play, yes?
_____________________
Yoofaloof Pacer
Registered User
Join date: 12 Apr 2005
Posts: 27
05-01-2006 04:42
Yes. I don't need to put the name of the sounds in the script do I?
Yoofaloof Pacer
Registered User
Join date: 12 Apr 2005
Posts: 27
05-01-2006 05:23
Apologies, it does work. Have no idea why it didn't work first time. Thanks very much.