Jump to content
Pixels Sideways

Need help with avatar detect name and listen script

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

Share this post


Link to post
Share on other sites

You can't use llDetetedName in anything but a touch*, collision*, or sensor event.  Listen events don't detect things.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Instead of "llDetectedKey(0)" use "llKey2Name(id)"

"id" is one of the input values the listen event has every time the event is triggered / the script hears something, and it's the key of whatever sent that message.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...