Jump to content

Show attachments and links to creators


Wulfie Reanimator
 Share

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

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

Recommended Posts

I was bored, tired of trying to right-click on someone's rigged attachment without an extra prim, and apparently some people pay for this.

So, here's a very simple script you'd wear on your HUD, click on it to get a text box, and type in the username of anyone on the sim. The script will then go through all of the public attachments (not HUDs) that person is wearing and list their names into chat with a clickable link to the creator's profile. (Example below)

integer channel;

list attachments; // UUIDs
integer count;
list namedAttachments; // Final

default
{
    state_entry()
    {
        channel = (integer)("0x"+llGetSubString(llGetKey(), 0, 7));
    }

    touch_start(integer n)
    {
        if(llDetectedKey(0) != llGetOwner()) return;

        llTextBox( llGetOwner(),
            "\n\nEnter an avatar's name in this sim."
            + " (channel " + (string)channel + ")", channel);
    }

    listen(integer channel, string name, key id, string message)
    {
        if(llName2Key(message)) // avatar is known to this region
        {
            attachments = llGetAttachedList(llName2Key(message));
            if( !(count = llGetListLength(attachments)) )
            {
                llOwnerSay("This weirdo hasn't got a single attachment.");
                return;
            }

            while(count--)
            {
                key attachment = llList2Key(attachments, count);
                string creator = llList2String(llGetObjectDetails(attachment, [OBJECT_CREATOR]), 0);
                string uri = "secondlife:///app/agent/"+creator+"/about";
                llOwnerSay(llKey2Name(attachment) + " " + uri);
            }
        }
        else llOwnerSay("No such avatar here.");
    }
}

Example output of a friend's current attachments:
d88584d8a7.png

Each attachment is said separately because of the character limit on llOwnerSay, which isn't enough to show all attachments at once in most cases.

Edited by Wulfie Reanimator
  • Like 4
Link to comment
Share on other sites

8 minutes ago, Ardy Lay said:

Might I suggest a strategic llListen(channel,"",llGetOwner(),""); be added as the second statement in state_entry?

That would seem fairly important, yes. I accidentally removed the line while editing my post and now we're past the 24-hour mark and the main post is locked.

Here's the script again with the llListen added (so it actually works). Better yet, I also added a script reset in case someone hands this script over to someone in-world.

integer channel;

list attachments; // UUIDs
integer count;
list namedAttachments; // Final

default
{
    changed(integer change)
    {
        if(change & CHANGED_OWNER) llResetScript();
    }
    
    state_entry()
    {
        channel = (integer)("0x"+llGetSubString(llGetKey(), 0, 7));
        llListen(channel, "", llGetOwner(), "");
    }

    touch_start(integer n)
    {
        if(llDetectedKey(0) != llGetOwner()) return;

        llTextBox( llGetOwner(),
            "\n\nEnter an avatar's name in this sim."
            + " (channel " + (string)channel + ")", channel);
    }

    listen(integer channel, string name, key id, string message)
    {
        if(llName2Key(message)) // avatar is known to this region
        {
            attachments = llGetAttachedList(llName2Key(message));
            if( !(count = llGetListLength(attachments)) )
            {
                llOwnerSay("This weirdo hasn't got a single attachment.");
                return;
            }

            while(count--)
            {
                key attachment = llList2Key(attachments, count);
                string creator = llList2String(llGetObjectDetails(attachment, [OBJECT_CREATOR]), 0);
                string uri = "secondlife:///app/agent/"+creator+"/about";
                llOwnerSay(llKey2Name(attachment) + " " + uri);
            }
        }
        else llOwnerSay("No such avatar here.");
    }
}

 

Edited by Wulfie Reanimator
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

TLDR Version: I really liked what @Wulfie Reanimator did, and added a HUD positioner and reports on script usage by (a) Attachments, (b) HUDs, and (c) Avatar total.  

// Erwin Solo
// Avatar Data Script 00.00.01
// 2019-06-23

// An expansion on a script by Wulfie Reanimator, See Second Life Scripting Libary June 2019

// Hud autopositioning based on Ferd Frederix script in OutWorldz repository 
// 

/*

A HUD to examine both Attachments and Script Time of any Avatar on the same SIM/Region as yourself, including examining your own Attachments and Script Time. 

Operation is simple.  

Step 1. Add the "!ES Avatar Data HUD" as a HUD.  

Step 2. Touch the "!ES Avatar Data HUD" to get a dialog box.

Step 3. Type the Legacy Name of a nearby Avatar into the dialog box and click the "Submit" button.  

    NOTE A.: You can type in your own legacy name, to get a report on yourself.

    NOTE B.: Legacy Names must be typed into the dialog box the form "First[ Last]" or "first[.last]" (first name with an optional last name.) If the last name is omitted a last name of "Resident" is assumed. Case is not considered when resolving agent names.  Reference: http://wiki.secondlife.com/wiki/LlName2Key


After you complete Steps 1 through 3, "!ES Avatar Data HUD" provides a report in local chat, visible only to you, the Owner of the "!ES Avatar Data HUD"

Report Part 1. Avatar Display Name (Avatar Legacy Name) for positive confirmation of your input.  If the Avatar you typed is not present on the SIM/Region, an error message will post.

Report Part 2. A list of Avatar attachments including Attachment Name, Attachment Creator, Attachment Script Time, Number of Scripts.

Report Part 3. 
    3.a. Script time SubTotal for all Avatar attachments.
    3.b. Script time SubTotal for all Avatar HUDs.  NOTE: Calculated by 3.c minus 3.a.  Scripts cannot directly examine HUDs on other Avatars.  
    3.c. Script time Grand Total for the Avatar.
    3.d Avatar Total Number of Scripts.
    
    
REVISION HISTORY
2019-06-23e: Added Script Count on a per-attachment and total avatar basis.
*/

integer  giLasttarget;

integer channel;

list attachments; // UUIDs
integer count;
list namedAttachments; // Final

default
{
    changed(integer change)
    {
        if(change & CHANGED_OWNER) llResetScript();
    }
    
    state_entry()
    {
        channel = (integer)("0x"+llGetSubString(llGetKey(), 0, 7));
        llListen(channel, "", llGetOwner(), "");
    }

    touch_start(integer n)
    {
        if(llDetectedKey(0) != llGetOwner()) return;

        llTextBox( llGetOwner(),
            "\nEnter an avatar's legacy name in this Region/SIM in the form of first name with an optional last name. If the last name is omitted a last name of Resident is assumed. Enter your own name for a report on yourself."
            , channel);
    }

    listen(integer channel, string name, key id, string message)
    {
        if(llName2Key(message)) // avatar is known to this region
        {
            float fAttachmentScriptTime = 0;
            string sOwner = llGetDisplayName(llName2Key(message)) + " (" + llKey2Name(llName2Key(message)) + ")";
            llOwnerSay("~~~~~~~~~~~~~~~~~\n" + "Report of Attachments for Avatar: " + sOwner);
            attachments = llGetAttachedList(llName2Key(message));
            if( !(count = llGetListLength(attachments)) )
            {
                llOwnerSay("This weirdo hasn't got a single attachment.");
                return;
            }

            while(count--)
            {
                key attachment = llList2Key(attachments, count);
                string creator = llList2String(llGetObjectDetails(attachment, [OBJECT_CREATOR]), 0);
                string uri = "secondlife:///app/agent/"+creator+"/about";
                
                float fScrTime = (1000 * (float)llList2String(llGetObjectDetails(attachment, [OBJECT_SCRIPT_TIME]), 0));
                fAttachmentScriptTime += fScrTime;
                string ScrTime = (string)fScrTime;
                string NumScripts = llList2String(llGetObjectDetails(attachment, [OBJECT_TOTAL_SCRIPT_COUNT]), 0);
                llOwnerSay(llKey2Name(attachment) 
                    + ", Creator: " + uri + 
                    ", Script Time: " + ScrTime + " ms, " + "Number of Scripts = " + NumScripts +".");
            }
            float sAvatarScriptTime = (1000 * (float)llList2String(llGetObjectDetails(llName2Key(message), [OBJECT_SCRIPT_TIME]), 0));
            float fHudScriptTime = sAvatarScriptTime - fAttachmentScriptTime;
            string AviScripts = llList2String(llGetObjectDetails(llName2Key(message), [OBJECT_TOTAL_SCRIPT_COUNT]), 0);
            llOwnerSay (
                "\n" + sOwner + " Script Time Report." 
                +"\n"+ (string)fAttachmentScriptTime + " ms: SubTotal for all Attachments." 
                +"\n"+ (string)fHudScriptTime +  " ms: SubTotal for all Huds."
                +"\n"+ (string)sAvatarScriptTime + " ms: Grand Total for Avatar " + sOwner + ".  "
                +"\n"+ "Avatar Total Number of Scripts = " + AviScripts +"."
                );
        }
        else llOwnerSay("The Avatar you named is not currently in this SIM/Region.  This script can only work if the named Avatar is in the same SIM/Region as you, or is near the shared boundary of an adjacent SIM/Region");
    }
    
        attach( key id)
    {
        rotation  myrot = llEuler2Rot( <0.0, 0.0, 0.0> * DEG_TO_RAD);
        llSetLocalRot(myrot);

        if(id)
        {
            integer target = llGetAttached();

            vector position = llGetLocalPos();

            if(target == giLasttarget )
                return;

            giLasttarget = target; // save the position we just set

            float Y = 0.0;
            float Z = 0.0;
            float trYoffset = 0.185;     // right edge
            float brYoffset = 0.125;     // right edge
            float otherYoffset = 0.080;      // move right from left edge
            float VerticalOffset = 0.2;        // move down for room for hover text
            float CenterOffset = 0.7;        // left and right center offset to left and right edge
            float BVerticalOffset = 0.080;     // Bottom Z.


            if(target == ATTACH_HUD_CENTER_2)
            {
                Y = CenterOffset; Z = 0.0;       // move to left edge
            }
            else if(target == ATTACH_HUD_TOP_RIGHT)
            {
                Y = trYoffset; Z = -VerticalOffset;      // down for room for hovertext
            }
            else if(target == ATTACH_HUD_TOP_CENTER)
            {
                Y = 0; Z = -VerticalOffset;
            }
            else if(target == ATTACH_HUD_TOP_LEFT)
            {
                Y = -otherYoffset; Z = -VerticalOffset;
            }
            else if(target == ATTACH_HUD_CENTER_1)
            {
                Y = -CenterOffset; Z = 0.0;      // move to right edge
            }
            else if(target == ATTACH_HUD_BOTTOM_LEFT)
            {
                Y = -otherYoffset; Z = BVerticalOffset;
            }
            else if(target == ATTACH_HUD_BOTTOM)
            {
                Y = 0.0; Z = BVerticalOffset;
            }
            else if(target == ATTACH_HUD_BOTTOM_RIGHT)
            {
                Y = brYoffset; Z = BVerticalOffset ;       // 2 x to miss buttons
            }
            else
            {
                llOwnerSay("You must attach this as a HUD");
                return;

            }

            vector newtarget = <0.0,Y,Z>;
            llSetPos(newtarget);

        }
    }
}

 

Edited by Erwin Solo
2019-06-23e: Added Script Count on a per-attachment and total avatar basis.
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1767 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...