Jump to content

Need help with avatar detect name and listen script


Pixels Sideways
 Share

You are about to reply to a thread that has been inactive for 2141 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 

PLEASE NOTE:  I figured out a workaround by placing the original touch script in the root -- however, I  would still like to know why this didn't work.  Thank you.

 

Hello:

I need help sorting out this script.

I have a listen script that works except for the avatar llDetectedName(0).   The list text comes up into chat but Instead of the avatars first name, it returns all 0's.    It worked fine as a standalone touch script but I need it to work in a child prim so created a listen script -- and need to have listens to send instructions to other child prime as well.

Thank you!

 

This is what pops up in chat:

The answer to your question, 00000000-0000-0000-0000-000000000000, is Blah blah blah..

 

This is the listen script in the child prim:

 

list linesofchat= 
[
"Blah blah blah.", 
"Yada yada yada.", 
"la la la la la la la.",

];

default
{
    state_entry()
    {
        llListen( 12345, "", NULL_KEY, "" ); 
    }

listen( integer channel, string name, key id, string message )
  {if ( message == "motorboat" )
    {
        integer j = llFloor(llFrand(llGetListLength(linesofchat)));
        string av = llDetectedName(0);
        av = llList2String(llParseString2List(av,[" "],[""]),0);
        llSay(0, "The answer to your question, " + av + ", is " + llList2String(linesofchat,j));      
    }
   } 
}

 

This is the call script in the root prim:

integer channel = 12345;


default
{

    touch_start(integer total_number)

            {
;
                llSay(channel,"motorboat");

            }
           
    
}
 


 

 

Edited by Pixels Sideways
Link to comment
Share on other sites

Rolig is, of course, completely right -- you can't use llDetected* in the listen event, but you don't need it.

When you open a listen event, you have four variables: integer channel, string name, key id, and string message. 

This means that anywhere in the listen event, you can refer to any one of those variables -- channel, name, id and message -- and the script will know you mean, respectively, the channel on which the message was sent (sometimes good to know if you are listening on several channels), the name of the avatar or object that sent the message, the uuid of that avatar or object, or the message itself.

Assuming you're trying to extract the avatar's first name, therefore, you need to say something like

string strFirstName = llList2String(llParseString2List(name,[" "],[""]),0);

and that should give you what you want.

ETA:  You could also try reading the speaker's display name, since that's presumably the name by which the speaker prefers to be known:

string strFirstName = llList2String(llParseString2List(llGetDisplayName(id),[" "],[""]),0);

 

Edited by Innula Zenovka
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2141 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...