Don't click here unless you want to be banned.

LSL Wiki : attach

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
attach(key id)

This event handler is triggered whenever the object is attached (which makes it an attachment) or detached from the avatar. If it is attached, id contains the key of the avatar it is attached to, otherwise id contains NULL_KEY.

Example:
default
{
    attach(key attached)
    {
        if (attached == NULL_KEY)  // object has been detached
        {
            llWhisper( 0, "Why hast thou forsaken me?" );
            // etc.
        }
        else   // object has been //attached//
        {
            llWhisper( 0, "I'm stuck on you, " + llKey2Name(attached) );
            // etc.
        }
    }
}

Note: if both on_rez and attach are used, on_rez will always be triggered first.

Note: when the object is detached to inventory, it will be given a limited amount of CPU cycles to run its attach event before it is derezed. There is no guarantee that all of the code within the attach event will complete before the derez occurs. In particular, expensive operations such as llSetPos may cause the script to be descheduled early, preventing timely execution of subsequent code.

Does not fire in child prims, only in root of linked objects.

Use the llAttachToAvatar, llDetachFromAvatar and llGetAttached functions to play with attachments.


Events | Agent/Avatar | Attachment
There are 5 comments on this page. [Display comments/form]