Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

click on an object with message and sound

dave2bwhipped Ansar
Registered User
Join date: 3 Oct 2008
Posts: 17
01-25-2009 07:00
HI,

Quick question

I am looking for a script that when an object is touched that it will desplay a certain message and with that message a certain sound. The script will need to have 5 messages in it and 5 sounds.

Anyone know of any or how to do this?

Thanks
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-25-2009 07:16
as explained in many other posts, this forum is not for free scripts, it's for help in creating/editing scripts. the new scripters thread at the top is there for a reason. either way, maybe this page will help you.

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llTriggerSound
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
01-25-2009 07:25
Several ways to do it, but it's difficult to know what to suggest in any details without first knowing the circumstances in which it's supposed to choose one message/sound combo rather than another.

However it makes that decision, the solution could well involve arranging your messages and sounds in two matching lists and having your object deliver message number n from list and play sound number n at the same time.

If it does, you will probably find http://www.lslwiki.net/lslwiki/wakka.php?wakka=llList2String,http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetInventoryName, and some of the functions at http://www.lslwiki.net/lslwiki/wakka.php?wakka=sound useful.

But you still have to decide how it's going to know what number n is.
dave2bwhipped Ansar
Registered User
Join date: 3 Oct 2008
Posts: 17
01-25-2009 07:37
From: Ruthven Willenov
as explained in many other posts, this forum is not for free scripts, it's for help in creating/editing scripts


Sorry Ruthven, Here is the script that I need to add the correct sounds to

As you can see the messages are already there and what I need is a specific sound (which I already have) to be played when a specific message is displayed.

list messages = [
"%N touches %V 's nipples and they stiffen.",
"%N rubs %V 's nipple, making %V moan.",
"%N pinches %V 's nipple, making %V whimper.",
"%N tugs on %V 's nipple, making %V 's nipple throb.",
"Rubbing in small circles %N stimulates %V 's nipples.",
"Pulling on %V 's nipples makes %V 's squirm."
];

//Extract just the first name (first word) from a string
string extractFirst( string wholeName )
{
list tokens = llParseString2List(wholeName, [" "],[]);
return llList2String(tokens, 0);
}

// Searches through string "src" for a pattern "pattern" and replaces it
// with string "value"
string replace_token(string src, string value, string pattern)
{
list tokens = llParseString2List(src, [" "],[]);
integer length = llGetListLength(tokens);
string new = "";
integer i=0;
string token = "";
for(i = 0; i < length; i++)
{
token = llList2String(tokens, i);
if(token == pattern) token = value;
if(i > 0)
new = new + " " + token;
else
new = token;
}
return new;
}

string next_template(list strings)
{
return llList2String(llListRandomize(strings, 1), 0);
}


//Build a random message from the list of messages.
string random_message(list templates)
{
string name = extractFirst(llDetectedName(0));
string victim = extractFirst(llKey2Name(llGetOwner()));
string message = replace_token(replace_token(next_template(templates), name, "%N";), victim, "%V";);
return message;
}

default
{
state_entry()
{
}

touch_start(integer total_number)
{
llSay(0, random_message(messages));
}
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-25-2009 09:33
LMAO OK now that we have verified that you are actually scripting it yourself and just need some help..........................................................

After reading the text I really need to wake up some more before tackling this one :p
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
01-27-2009 05:03
Try something based on this, replacing "sound1", "sound2", and so on, with the names of the sound associated with the particular message.
CODE
list messages_sounds = [
"%N touches %V 's nipples and they stiffen.","sound1",
"%N rubs %V 's nipple, making %V moan.","sound2",
"%N pinches %V 's nipple, making %V whimper.","sound3",
"%N tugs on %V 's nipple, making %V 's nipple throb.","sound4",
"Rubbing in small circles %N stimulates %V 's nipples.","sound5",
"Pulling on %V 's nipples makes %V 's squirm.","sound6"
];


string extractFirst( string wholeName )
{
list tokens = llParseString2List(wholeName, [" "],[]);
return llList2String(tokens, 0);
}

string replace_token(string src, string value, string pattern)
{
list tokens = llParseString2List(src, [" "],[]);
integer length = llGetListLength(tokens);
string new = "";
integer i=0;
string token = "";
for(i = 0; i < length; i++)
{
token = llList2String(tokens, i);
if(token == pattern) token = value;
if(i > 0)
new = new + " " + token;
else
new = token;
}
return new;
}
string toucher;
string touchee;

default
{
state_entry()
{
touchee = extractFirst(llKey2Name(llGetOwner()));
}

touch_start(integer total_number)
{
toucher = extractFirst(llDetectedName(0));

messages_sounds = llListRandomize(messages_sounds, 2);
list temp =[]; // not sure it it's necessary to empty the list each time but it can't hurt.
temp = llList2List(messages_sounds,0,1);
string mystring = llList2String(temp,0);
mystring = replace_token(mystring, touchee, "%V");
mystring = replace_token(mystring, toucher, "%N");
string mysound = llList2String(temp, 1);
llPlaySound(mysound, 1.0);
llSay(0, mystring);

}
}
I'm sure it can be expressed more economically -- I broke it down step by step so I could see what I was doing.

I'm not sure what, if anything, you need to do about preloading the sounds, or when you would need to do it. Maybe someone who knows more about sounds than do I could assist.