Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Animation by attachment

Absinthe Sautereau
Registered User
Join date: 26 Mar 2007
Posts: 86
05-17-2007 10:11
I think I have reposted thsi in three different forums so far. If you are tired of seeing it please forgive me as I keep moving it when people tell me "this would probably better be answered by ...'

I have an attachment that some of my friends can wear, it will animate them based on something I say (llListen). I would like to change it such that I can add their name to it, or some part of their name maybe. Example: "-SitDown" now will make everyone in my voice range sit. I would like just Johnny Blurf to sit down so I would like to say "Johnny SitDown" or "-SitDown Johnny" or "-SitDown J" if he is the only one wearing it with a first name startign with "J".

I have seen the posing attachments that you cna says "hug Zel" that will then approach Zeldini Hooberflatchet because that is the only person whos name matches Zel, then offers to animate that icon. I guess I am looking to do it in reverse, listening for some command you understand, then parsing the rest of the command to discern if it may be aimed at you, based on your first name or whole name or some part of it.

Obviously I am already getting to the point that I detected that -SitDown was said. How can I get the rest of the line in which it was spoken? And how do I get the wearing avatar's name?

The other direction may be listening instead of listening for -SitDown to somehow listen for <getMyFirstName>+' SitDown'
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
05-17-2007 10:53
There is a sample script I have seen, but don't have handly right now name partialname, or you can look at the hugger script, its free and give full rights.
But the function you are looking for is llKey2Name(llGetOwner()).
Who will also want to convert the name and the compare to lower cases for the matching.
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
05-17-2007 10:57
Something here may help get you started...

CODE
//The name of the owner of an object:

avName = llToLower(llKey2Name(llGetOwner()));


//The tagrget name parsed from the string data = "-SitDown name":

tgtName = llGetSubString(data, 9, -1);


//A condition to match the target name with the owner name:

if (llSubStringIndex(llToLower(tgtName), avName) >= 0
Absinthe Sautereau
Registered User
Join date: 26 Mar 2007
Posts: 86
05-17-2007 12:13
Pale Spector --

Ok that is kind of what I was initially thinking. There are a few clarificatons I am just wanting to make sure of:

is Owner always the av wearing the attachment in which the script resides?
llSubStringIndex seems to return the end of where it was found? So "John" searching in "John Binderwiggle" will return 4 I suppose. Which is fine I guess as long as it returns somethgin >=0.

So if I use

CODE

list theList = llParseString2List(tgtName, " ","");
integer index = 0;
string element="";
integer length = llGetListLength(theList);
for (index = 0; index < length; ++index)
{
element = llList2String(theList , index);
if (llSubStringIndex(llToLower(tgtName), element) >= 0
{
... respond to command ...
jump getOut;
}
}
@getOut;

That should handle the situation such as if I say "-SitDown John if you please" or even "-SitDown John Jack and Alice" or even "-SitDown Mr. Binderwiggle"

Hopefully I have thought this through correctly. Suggestions or critiques, best practices etc..
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
05-17-2007 13:11
Only the owner can actually be wearing an object - not to be confused with the creator: llGetCreator()

llSubStringIndex will return the first position in the string (in your example that would be 0), and -1 indicates there was no match.


I think your syntax for llParseString2List is wrong and should be:

list theList = llParseString2List(tgtName, [" "], [""]);

...as the separators and spacers parameters are both lists.


In your code I'm suspicious of your logic for:

if (llSubStringIndex(llToLower(tgtName), element) >= 0

...which I think should be:

if (llSubStringIndex(llToLower(llKey2Name(llGetOwner())), element) >= 0


I'm assuming tgtName is the phrase you're searching split into separate words in the list theList, and that you want to search for each of these words in the owners name.

So, if we had the phrase: "You're looking pale Absinthe, please sit down" ... I'd sit. :p
Absinthe Sautereau
Registered User
Join date: 26 Mar 2007
Posts: 86
05-17-2007 13:23
Well, I was making the assumption that I would still actually be listening fro the command
"-SitDown" as the token upon which to act. Does the llisten actually hear stuff that doesn't start the line?

tgtName was your example of all the text following "-sitDown" using

tgtName = llGetSubString(data, 9, -1);

if I split that to a list I shoudl get
["John","if","you","please"]
or
["John","Jack","and", "Alice"]
or
["Mr.", "Binderwiggle""]

Now however, that I think of it, I actually want it to match the beginning of either the first name or the last name. So I suspect I must split that as well and do a double test. Certainly if I say "-SitDown John if you please" I woudl like john to sit down, but not necessarily Jiffrow or Apleasia to sit down. Obviously it will be a bit fuzzy and I am sure I will get some odd results if I get too flowery in my speach, but I can try and control myself :)

Looking back at the code, I see where I probably meant to use avName from:
avName = llToLower(llKey2Name(llGetOwner()));

in the comparison to the element. Though in reality in light of what I said above, I want to make it a list, split in to firstName and lastName then compare looking for a 0 result sayign that I match the beginning of either name.