Triggered in an object when the object attaches or detaches from agent.

Syntax

attach( key id )

Event ID: 23.

Parameters

key id
the avatar if attached, if not attached NULL_KEY.

Specification

Triggered

  1. When the object is attached to an avatar
  2. When object is detached (id == NULL_KEY)

Not Triggered

  1. When the avatar wearing the object teleports
  2. When the avatar wearing the object moves from one region to another
  3. When the attachment is detached after being attached with llAttachToAvatarTemp.

Caveats

Examples

The following is a simplified example of the attach event. The variable id will be the key of the avatar the scripted object is attached to otherwise it will take on the value of NULL_KEY. The conditional if statement is used to determine the value of the variable id.

default
{
    attach(key id)
    {
        if (id)     // is a valid key and not NULL_KEY
        {
            llSay(0, "I have been attached!");
        }
        else
        {
            llSay(0, "I have been detached!");
        }
    }
}

Notes

on_rez & attach

on_rez will be triggered prior to attach when attaching from inventory or during login.

See also

Events

Functions

Articles

Deep notes

Issues