Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sound script

Laurie Partridge
Retro Goddess
Join date: 1 Jun 2004
Posts: 73
07-30-2006 14:23
Hi All. I've taken on a fairly ambitious (
for me :D) project. It is almost completed, but I've hit a stone wall and can't get any further. I'm hoping someone out there can help. I did a forum search but couldn't find exactly what I am looking for.

I've created an object that I would like to play certain sounds. Here is how it should work:

Clicking on the object will bring up a list of sounds, from which the object's owner can then select which sound to play. The sounds will all be loaded into the objects contents. The sounds should only play one time (not looped).

Other things to consider: The object is a multi-prim avatar. One prim (the chest) will be used to play a looped "background" sound when clicked. This part is all set up already and works fine. Another prim (the head) will have all the other sounds loaded for the user to select (also when clicked). Are there any "root prim" issues that will make this hard to do?

Also, the list of sounds is fairly extensive, so any pop-up window may need to have categories to select from, for ease of use.

Does anything like this already exist? If not, is there a scripter willing to tackle this for a fee?

Thanks so much for any and all help!
_____________________
Zapoteth Zaius
Is back
Join date: 14 Feb 2004
Posts: 5,634
07-30-2006 15:03
llDialog seems to be what you're looking for. I'm not a scripter so the best advice I can give is to play around with it. Not sure if this was the kinda information you were looking for :p, but figured I'd post it on the off chance it'd help!

Zap
_____________________
I have the right to remain silent. Anything I say will be misquoted and used against me.
---------------
Zapoteth Designs, Temotu (100,50)
---------------
Danielle Bradley
Registered User
Join date: 26 May 2006
Posts: 21
07-30-2006 15:51
Does the list of sounds stay the same, or does the script need to read them from a notecard so the owner can change them easily? The llDialogs would be easier to write if they stay the same.
Laurie Partridge
Retro Goddess
Join date: 1 Jun 2004
Posts: 73
07-30-2006 18:10
From: Danielle Bradley
Does the list of sounds stay the same, or does the script need to read them from a notecard so the owner can change them easily? The llDialogs would be easier to write if they stay the same.


The sounds would always remain the same. I took a look at ||Dialogs. This statement confuses me, though: Selecting any of the buttons will cause the avatar to say the text of that button on channel chat_channel.

Can this script be configured to play the sounds instead of causing the avatar to say text?

Sorry if these are dumb questions, scripting REALLY confuses me. :)
_____________________
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
07-30-2006 22:49
what the buttons in llDialog do is make your av say a /xx command

so instead of foricing the user to say /66 play they just hit a button, you get the results in the listen event,

if (message == "play";) llDo_Play_Sound_stuff;


llDialog(llGetOwner(),"please choose",["play","stop"],66);
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
07-31-2006 01:50
From: Laurie Partridge
The sounds would always remain the same. I took a look at ||Dialogs. This statement confuses me, though: Selecting any of the buttons will cause the avatar to say the text of that button on channel chat_channel.

Can this script be configured to play the sounds instead of causing the avatar to say text?

Sorry if these are dumb questions, scripting REALLY confuses me. :)


Don't quote me exactly on this (doing it from memory):

CODE

integer MENU_CHANNEL = -198284; // Or ohther negative number: negative channels wont show AV saying!
list MENU_OPTIONS = ["sound1","sound2","sound3","sound4"];
integer channelControl;

default
{
state_entry()
{
// Not shown here but looping the menu_options you could use
// llPreloadSound() - see LSL wiki
channelControl = llListen(MENU_CHANNEL,"",NULL_KEY,"");
llListenControl(channelControl,FALSE); // Don't listen just yet
}

touch(integer num_detected)
{
llListenControl(channelControl,TRUE); // Start listening for response
llSetTimerEvent(60); // Make sure 60s from now channel is closed again
llDialog(llDetectedKey(0),"Select the sound:",MENU_OPTIONS,MENU_CHANNEL);
}

listen(integer channel,string who,key id,string message)
{
if (channel==MENU_CHANNEL)
{
// message = name of button
// assume button name = name of soundfile
llPlaySound(message,1.0);
// Done, stop timer and channel
llSetTimerEvent(0);
llChannelControl(channelControl,FALSE);
}
}

timer()
{
// Timeout wiating for dialog response,stop timer and channel
llSetTimerEvent(0);
llChannelControl(channelControl,FALSE);
}
}
Laurie Partridge
Retro Goddess
Join date: 1 Jun 2004
Posts: 73
07-31-2006 16:59
First, thanks to everyone for their responses. Unfortunately, I am no closer than when I began. :(

Osgeld, I understand the first part of your response. But when I use the llDialog script from the Wiki, it makes the object speak, not me (or the object's owner). And clueless me has no idea what to do with the code you posted. :D

Marcuw, I tried the script you posted, but got an error message when I tried to save it.

I'll keep trying, but any other input would be greatly appreciated.
_____________________
Drizzt Naumova
Teh Foxeh DJ
Join date: 9 Oct 2005
Posts: 116
07-31-2006 17:26
hehe, its a simple typo in the script :) this one wil compile successfully
needed to change the 2 llChannelControl's towards the bottom to llListenControl
CODE

integer MENU_CHANNEL = -198284; // Or ohther negative number: negative channels wont show AV saying!
list MENU_OPTIONS = ["sound1","sound2","sound3","sound4"];
integer channelControl;

default
{
state_entry()
{
// Not shown here but looping the menu_options you could use
// llPreloadSound() - see LSL wiki
channelControl = llListen(MENU_CHANNEL,"",NULL_KEY,"");
llListenControl(channelControl,FALSE); // Don't listen just yet
}

touch(integer num_detected)
{
llListenControl(channelControl,TRUE); // Start listening for response
llSetTimerEvent(60); // Make sure 60s from now channel is closed again
llDialog(llDetectedKey(0),"Select the sound:",MENU_OPTIONS,MENU_CHANNEL);
}

listen(integer channel,string who,key id,string message)
{
if (channel==MENU_CHANNEL)
{
// message = name of button
// assume button name = name of soundfile
llPlaySound(message,1.0);
// Done, stop timer and channel
llSetTimerEvent(0);
llListenControl(channelControl,FALSE);
}
}

timer()
{
// Timeout wiating for dialog response,stop timer and channel
llSetTimerEvent(0);
llListenControl(channelControl,FALSE);
}
}


This will compile correctly :) also tested it in world. Credits still go to Marcuw :D Simple script errors..gah..gotta love em :P
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
08-01-2006 08:55
From: Drizzt Naumova
hehe, its a simple typo in the script :) this one wil compile successfully
needed to change the 2 llChannelControl's towards the bottom to llListenControl
This will compile correctly :) also tested it in world. Credits still go to Marcuw :D Simple script errors..gah..gotta love em :P


TY :)
Big typeying errors tho... But then again.. was at work and quickly worked it up...
Laurie Partridge
Retro Goddess
Join date: 1 Jun 2004
Posts: 73
08-01-2006 15:16
Thank you, thank you, thank you, thank you, thank you ALL!! It works perfectly!
_____________________
Drizzt Naumova
Teh Foxeh DJ
Join date: 9 Oct 2005
Posts: 116
08-02-2006 14:23
While we are on the topic..is there a way to add an option for the dialog to get the list of sounds and names of the sounds in the inventory and list them in the dialog? I think it is used with llGetInventoryNumber and llGetInventoryName, but not sure..still sorta rough around the edges with my scripting abilities hehe. I think that would be much better to use in a script like that than having to go in and list more menu buttons and menu sounds manually. Would be more efficient that way IMHO :)
jrrdraco Oe
Insanity Fair
Join date: 28 Oct 2005
Posts: 372
08-02-2006 18:12
I think it is easier if you make a notecard and list all the sounds in it, getting inventory names would bring up animations, scripts and other stuff. Unless you set a rule for sounds like "fx_soundfile" and filter inventory items by "fx_"
_____________________
--
Linux Specs: http://www.immerdrauf.com/jrrhack/specs.txt
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
08-04-2006 03:02
From: Drizzt Naumova
While we are on the topic..is there a way to add an option for the dialog to get the list of sounds and names of the sounds in the inventory and list them in the dialog? I think it is used with llGetInventoryNumber and llGetInventoryName, but not sure..still sorta rough around the edges with my scripting abilities hehe. I think that would be much better to use in a script like that than having to go in and list more menu buttons and menu sounds manually. Would be more efficient that way IMHO :)


From head again, just code snippets (might not work directly):
CODE

list get_sounds_from_inventory()
{
list sounds=[];
integer i=0;
integer count=llGetInventoryNumber(INVENTORY_SOUND);
while (i<count)
{
sounds = (sounds=[]) + sounds + [llGetInventoryName(INVENTORY_SOUND,i)];
i += 1;
}
return sounds;
}

If you want to use the actual sounds linked with a name, you should use a notecard. LSL Wiki contains a very good example how to do that.
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
08-04-2006 03:04
From: jrrdraco Oe
I think it is easier if you make a notecard and list all the sounds in it, getting inventory names would bring up animations, scripts and other stuff. Unless you set a rule for sounds like "fx_soundfile" and filter inventory items by "fx_"

Not true. Specify the type of inventory you want to receive.

Notecards are only needed if you want to map obscure names to understandable (human) dancenames...