Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

HUD-triggered animation

Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
09-10-2006 15:06
With apologies - I realise it can't be all that difficult, as we see them all the time.
But, after hours & hours of searching for the right advice, I'm still none the wiser.

I want to give the visitor an opportunity to choose whether or not to play a sound, based on a male or female voice. It's not a massive event, so really I don't expect people to mess about with custom gestures & so forth.

Ideally, there would be a HUD display asking "Do you want to play a sound?" with the possible responses of "No thanks"; "Female Voice"; "Male Voice". Pressing one of the last 2 buttons would grant permissions.

HOW do you do this????!
Please advise, if you can!

Cheers,
Cherry :o
_____________________
=================
My stuff on XSt:-
http://tinyurl.com/383mgh
HtF Visconti
Registered User
Join date: 21 Jul 2006
Posts: 123
09-10-2006 22:41
Hi,

I am missing some info here .... what is it we are talking about? A thing to click on, a thing to wear, a thing to sit on?

The method of triggering the sound does depend a bit on an answer to the above questions.

Once answered the rest is pretty easy. :)
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
09-10-2006 22:48
You could use llDialog which will appear on top right hand corner of user's screen.
You have the avatar's key, make a list of choices, and provide a listener on some channel number and you are done!
http://rpgstats.com/wiki/index.php?title=LlDialog

You would still need to ask permissions
HtF Visconti
Registered User
Join date: 21 Jul 2006
Posts: 123
09-11-2006 01:33
What would you need to ask permissions for? OK - I still do not know what type of object we're talking here (sit-target, attachment, touch me object) but for playing a sound you do *not* need permissions.

The menu would just offer choices and depending on the key pressed this would be like "asking the user for permission to play a sound" but in LSL terms permissions are something else entirely and shouldn't be confused with this issue here.

I do currently not have access to SL so this is off the brain with no tests being done. It *does* compile but if it runs .... it assumes a prim/object which will present a dialogue on touch.

CODE

//===============================
// Sound Sample Dialogue Script
// 2006 by HtF
// Free to use and distribute
// !! UNTESTED !!
// ==============================

//==================================================
// program variables
//==================================================

list soundlist = ["malesound", "femalesound"]; // Insert real soundnames here
list soundmenu = ["Male", "Female"]; // Menu to display on HUD - ignore is inbuilt
integer menuchannel; // Channel for the menu

//==================================================
// default
//==================================================


default
{

state_entry() {
//
// Remove the preload commands if they delay the script too much
// but expect wait time between the touch and the playing of the sound
// if it is removed
//
menuchannel = (integer)(llFrand(5000)) + 10000 * -1;
llPreloadSound(llList2String(soundlist,0)); // Heavy delay penalty but makes sure there is no wait time when sound plays
llPreloadSound(llList2String(soundlist,1)); // Heavy delay penalty but makes sure there is no wait time when sound plays
}

on_rez (integer start_param) {
llResetScript();
}

touch_start(integer total_number)
{
//
// Display the menu
//
llDialog(llDetectedKey(0),"\nPlease select which sound to play:\n",soundmenu,menuchannel);
}


changed( integer change )
{
//
// Reset script if anything in the inventory changes
//

if( change == CHANGED_INVENTORY ) {
llResetScript();
}

}

listen(integer channel, string name, key id, string message) {
//
// Add as many if conditions as you have choices in your menu
//
if (message == "Male") {
llStopSound(); // Remove this if your sounds are short and you do not want to have them interrupted
llPlaySound(llList2String(soundlist,0),1);
}
if (message == "Female") {
llStopSound(); // Remove this if your sounds are short and you do not want to have them interrupted
llPlaySound(llList2String(soundlist,1),1);
}
}
}


The above is quick and dirty - no timeout for the menu but should serve as a starting point.
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
09-11-2006 01:51
couple things with the above code

Add following line to state_entry (somewhere after the assigning of menuchannel. I usually put llListen's at the end of the state_entry.)
CODE

llListen(menuchannel, "", NULL_KEY, "");

and to make it more dynamic (add more sounds and buttons easily at the top of the script)

CODE

listen(integer channel, string name, key id, string message)
{
integer choice = llListFindList(soundmenu, [message]);

if (choice != -1) // If it was found
{
llStopSound(); // Remove if sounds are short and shouldn't be interupted
llPlaySound(llList2String(soundlist,choice),1);
}
}


Now all you have to do is add sounds to the soundlist, and their corosponding buttons to soundmenu. Oh, and make sure they are both in the same order.
HtF Visconti
Registered User
Join date: 21 Jul 2006
Posts: 123
09-11-2006 02:04
Lol - this comes from not testing ingame .... I admit the installation of the listener does kind of help :)
Cherry Hainsworth
Registered User
Join date: 31 Jul 2006
Posts: 125
09-11-2006 08:22
Thanks a million, you two - it works great!!

You now have the choice between a girly scream and a Tarzan yell when sliding down my water chute :D

Cherry ["Aaaaaaaaggggghhhhhh!"]
_____________________
=================
My stuff on XSt:-
http://tinyurl.com/383mgh