Difference between revisions of "Attach"

From Second Life Wiki
Jump to navigation Jump to search
m
m
Line 53: Line 53:
|also_footer
|also_footer
|notes=
|notes=
===[[attach]] & [[on_rez]]===
===[[on_rez]] & [[attach]]===
[[on_rez]] will be triggered prior to [[attach]] when attaching from inventory or during login.
[[on_rez]] will be triggered prior to [[attach]] when attaching from inventory or during login.



Revision as of 22:51, 15 April 2009

Description

Event: attach( key id ){ ; }

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

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

Specification

Triggered

  1. When the object is attached to an avatar
    • From the ground
    • From inventory
    • When the avatar wearing the object logs in
  2. When object is detached (id == NULL_KEY)
    • Dropped to the ground
    • Derezzed to inventory
    • When the avatar wearing the object logs out

Not Triggered

  1. When the avatar wearing the object teleports
  2. When the avatar wearing the object moves from one region to another

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. <lsl>default {

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

}</lsl>

Notes

on_rez & attach

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

Derez Timing

Durring derez, an object is only given so much time to execute it's attach events. If these events are active when the script derezzes but have not completed, execution will finish when the object is next rezzed (this may not be desirable). It is advisable to keep you detach code simple.

See Also

Events

• on_rez

Functions

• llAttachToAvatar
• llDetachFromAvatar
• llGetAttached

Articles

• Attachment

Deep Notes

Signature

event void attach( key id );