# Linksets

> Objects made of several linked prims: link numbers, linking, rezzing and object details.

An object is a linkset: one root prim plus any child prims, moving and rezzing as a unit. Each prim has a link number. The root is 1 when there are several prims, and 0 in a single-prim object. Seated avatars are added after the prims.

Most prim functions have a Link variant that works on any prim by link number, so one script can control the whole object. What a single prim looks like is covered by [Prims](/features/prims/).

## Concepts

- Every prim has a [link number](/functions/llGetLinkNumber/); the object has a [number of prims](/functions/llGetNumberOfPrims/) (including seated avatars) and a [prim count](/functions/llGetObjectPrimCount/)
  - Special link constants address [the root](/constants/LINK_ROOT/), [this prim](/constants/LINK_THIS/), [all prims](/constants/LINK_SET/), [all others](/constants/LINK_ALL_OTHERS/) or [all children](/constants/LINK_ALL_CHILDREN/)
  - [Names](/functions/llGetLinkName/) and [keys](/functions/llGetLinkKey/) help find a prim by role instead of by number, because numbers change when the object is relinked
- [Linking](/functions/llCreateLink/) and [unlinking](/functions/llBreakLink/) need `PERMISSION_CHANGE_LINKS` from the owner
  - The [`changed`](/events/changed/) event reports [`CHANGED_LINK`](/constants/CHANGED_LINK/)
- One script can [set](/functions/llSetLinkPrimitiveParamsFast/) or [read](/functions/llGetLinkPrimitiveParams/) many properties of any prim, or several prims, in one call
  - Scripts in different prims talk with [link messages](/functions/llMessageLinked/)
- The object as a whole has a [root position](/functions/llGetRootPosition/), a [bounding box](/functions/llGetBoundingBox/), a [mass](/functions/llGetObjectMass/) and an owner, and can be [scaled](/functions/llScaleByFactor/) as a unit
  - [Details of other objects](/functions/llGetObjectDetails/) are read by key
- Objects in inventory can be [rezzed](/functions/llRezObject/) with a position, velocity and parameters
  - [`llRezObjectWithParams`](/functions/llRezObjectWithParams/) sets many properties at rez time
  - The child receives the start parameter in [`on_rez`](/events/on_rez/)
  - Objects can [delete themselves](/functions/llDie/) or [derez others they own](/functions/llDerezObject/)

## Functions and events

- `integer` [`llGetLinkNumber`](/functions/llGetLinkNumber/) `()`
- `integer` [`llGetNumberOfPrims`](/functions/llGetNumberOfPrims/) `()`
- `string` [`llGetLinkName`](/functions/llGetLinkName/) `(integer link)`
- `key` [`llGetLinkKey`](/functions/llGetLinkKey/) `(integer link)`
- `void` [`llCreateLink`](/functions/llCreateLink/) `(key target, integer parent)`
- `void` [`llBreakLink`](/functions/llBreakLink/) `(integer link)`
- `void` [`llSetLinkPrimitiveParamsFast`](/functions/llSetLinkPrimitiveParamsFast/) `(integer link, list rules)`
- `list` [`llGetLinkPrimitiveParams`](/functions/llGetLinkPrimitiveParams/) `(integer link, list params)`
- `void` [`llMessageLinked`](/functions/llMessageLinked/) `(integer link, integer num, string str, key id)`
- `key` [`llRezObjectWithParams`](/functions/llRezObjectWithParams/) `(string item, list options)`
- `event` [`on_rez`](/events/on_rez/) `(integer start_param)`
- `event` [`changed`](/events/changed/) `(integer changes)`

## [Rezzing](https://wiki.secondlife.com/wiki/Category:LSL_Rez)

Rez objects from inventory, pass them a start parameter or string, and derez them later.

## Scripting Details

### Link numbers functions

- `integer` [`llGetLinkNumber`](/functions/llGetLinkNumber/) `()`: Returns the integer link number of the prim containing the script (0 for unlinked, 1 for the root, and 2+ for children).
- `integer` [`llGetNumberOfPrims`](/functions/llGetNumberOfPrims/) `()`: Returns an integer representing the total number of prims and seated avatars in the linkset containing the script.
- `integer` [`llGetObjectPrimCount`](/functions/llGetObjectPrimCount/) `(key prim)`: Returns an integer representing the total number of prims in the object containing the specified prim.
- `string` [`llGetLinkName`](/functions/llGetLinkName/) `(integer link)`: Returns a string containing the name of the linked prim specified by link.
- `key` [`llGetLinkKey`](/functions/llGetLinkKey/) `(integer link)`: Returns the key (UUID) of the linked prim or avatar specified by link.
- `integer` [`llGetLinkNumberOfSides`](/functions/llGetLinkNumberOfSides/) `(integer link)`: Returns an integer representing the number of sides (faces) of the linked prim specified by link.
- `integer` [`LINK_ROOT`](/constants/LINK_ROOT/) `= 1`: Refers to the root prim of the linkset.
- `integer` [`LINK_SET`](/constants/LINK_SET/) `= -1`: Refers to every prim in the linkset.
- `integer` [`LINK_THIS`](/constants/LINK_THIS/) `= -4`: Refers specifically to the single prim containing the running script.
- `integer` [`LINK_ALL_OTHERS`](/constants/LINK_ALL_OTHERS/) `= -2`: Refers to every other prim in the linkset, excluding the prim containing the script.
- `integer` [`LINK_ALL_CHILDREN`](/constants/LINK_ALL_CHILDREN/) `= -3`: Refers to all child prims in the linkset (every prim except the root).

### Linking and unlinking

- `void` [`llCreateLink`](/functions/llCreateLink/) `(key target, integer parent)`: Attempts to link the object containing the script with target. Requires the PERMISSION_CHANGE_LINKS runtime permission.
- `void` [`llBreakLink`](/functions/llBreakLink/) `(integer link)`: Delinks the prim specified by the link number link. Requires the PERMISSION_CHANGE_LINKS runtime permission.
- `void` [`llBreakAllLinks`](/functions/llBreakAllLinks/) `()`: Delinks all prims in the linkset. Requires the PERMISSION_CHANGE_LINKS runtime permission, which must be requested and granted by the owner.
- `event` [`changed`](/events/changed/) `(integer changes)`: Triggered when various properties of the object change. The parameter changes is a bitfield of CHANGED_* flags.
- `integer` [`CHANGED_LINK`](/constants/CHANGED_LINK/) `= 0x20`: Number of prims making up the object or avatars seated on it has changed. Also occurs when duplicating a linked object or when a prim changes type or shape. Does not trigger on attach/detach, sit/unsit in attachments, or single prim duplication.
- `integer` [`PERMISSION_CHANGE_LINKS`](/constants/PERMISSION_CHANGE_LINKS/) `= 0x00080`: Runtime permission that allows the script to successfully create, break, or modify links to other objects using llCreateLink, llBreakLink, or llBreakAllLinks.

### Controlling every prim

- `void` [`llSetLinkPrimitiveParamsFast`](/functions/llSetLinkPrimitiveParamsFast/) `(integer link, list rules)`: Sets primitive parameters for the linked prim link according to rules with no built-in script sleep delay.
- `list` [`llGetLinkPrimitiveParams`](/functions/llGetLinkPrimitiveParams/) `(integer link, list params)`: Returns a list of primitive parameters requested in params for the linked prim specified by link (equivalent to llGetPrimitiveParams).
- `void` [`llSetLinkColor`](/functions/llSetLinkColor/) `(integer link, vector color, integer face)`: Sets the Blinn-Phong diffuse RGB color of face on the linked prim link.
- `void` [`llSetLinkAlpha`](/functions/llSetLinkAlpha/) `(integer link, float alpha, integer face)`: Sets the Blinn-Phong alpha (transparency) of face on the linked prim link.
- `void` [`llSetLinkTexture`](/functions/llSetLinkTexture/) `(integer link, string texture, integer face)`: Applies texture (UUID or inventory name) to face of the linked prim link.
- `void` [`llMessageLinked`](/functions/llMessageLinked/) `(integer link, integer num, string str, key id)`: Triggers a link_message event, sending num, str, and id to the scripts in the prim(s) specified by link to allow scripts within the same object to communicate.

### The object as a whole functions

- `vector` [`llGetRootPosition`](/functions/llGetRootPosition/) `()`: Returns a vector representing the position (in region coordinates) of the root prim of the linkset containing the script.
- `rotation` [`llGetRootRotation`](/functions/llGetRootRotation/) `()`: Returns a rotation representing the orientation (relative to the region) of the root prim of the linkset containing the script.
- `list` [`llGetBoundingBox`](/functions/llGetBoundingBox/) `(key object)`: Returns the bounding box of object (including any linked prims) relative to its root prim in local coordinates, formatted as [ (vector) min_corner, (vector) max_corner ].
- `vector` [`llGetGeometricCenter`](/functions/llGetGeometricCenter/) `()`: Returns a vector representing the geometric center of the object relative to its root prim.
- `vector` [`llGetCenterOfMass`](/functions/llGetCenterOfMass/) `()`: Returns the vector position (in region coordinates) of the center of mass. Returns the individual child prim's center of mass if called from a child, or the entire linkset's center of mass if called from the root.
- `float` [`llGetObjectMass`](/functions/llGetObjectMass/) `(key id)`: Returns a float representing the mass of the avatar or object specified by id.
- `list` [`llGetObjectDetails`](/functions/llGetObjectDetails/) `(key id, list params)`: Returns a list containing the requested parameters of the specified avatar or object id, retrieved in the order requested by params.
- `key` [`llGetOwnerKey`](/functions/llGetOwnerKey/) `(key id)`: Returns the key (UUID) of the owner of the prim specified by id.
- `key` [`llGetCreator`](/functions/llGetCreator/) `()`: Returns the key (UUID) of the prim's original creator.
- `integer` [`llScaleByFactor`](/functions/llScaleByFactor/) `(float scaling_factor)`: Attempts to uniformly resize the entire object by scaling_factor, maintaining size-position ratios of the prims. Fails if the linkset is physical, a pathfinding character, in keyframed motion, would exceed prim scale/linkability limits, or would overflow parcel capacity.
- `float` [`llGetMaxScaleFactor`](/functions/llGetMaxScaleFactor/) `()`: Returns a float representing the maximum scale factor that can be applied to the object via llScaleByFactor without violating size or linkability limits.
- `float` [`llGetMinScaleFactor`](/functions/llGetMinScaleFactor/) `()`: Returns a float representing the minimum scale factor that can be applied to the object via llScaleByFactor without violating size limits.

### Rezzing objects functions

- `key` [`llRezObjectWithParams`](/functions/llRezObjectWithParams/) `(string item, list options)`: Instantiates the named inventory object (defaulting to the rezzing prim's position unless REZ_POS is specified) using the initial set of parameters specified in options. Returns the key of the rezzed object, or a blank key on failure.
- `void` [`llRezObject`](/functions/llRezObject/) `(string item, vector pos, vector vel, rotation rot, integer start_param)`: Instantiates the named inventory object with the bounding box centered at pos with velocity vel and rotation rot, passing param as the on_rez start parameter. The vel parameter is ignored if the rezzed object is non-physical.
- `void` [`llRezAtRoot`](/functions/llRezAtRoot/) `(string item, vector pos, vector vel, rotation rot, integer start_param)`: Instantiates the named inventory object with the root prim at pos with velocity vel and rotation rot, passing start_param as the on_rez start parameter. The vel parameter is ignored if the rezzed object is non-physical.
- `event` [`object_rez`](/events/object_rez/) `(key id)`: Triggered when this object successfully rezzes another object from its inventory. Passes the key (UUID) id of the newly rezzed object.
- `event` [`on_rez`](/events/on_rez/) `(integer start_param)`: Triggered when the object is rezzed into the world (by a script or user). Passes start_param from the rezzing call (or 0 if rezzed from inventory). Also triggers on attachments during login or when attached from inventory.
- `integer` [`llGetStartParameter`](/functions/llGetStartParameter/) `()`: Returns an integer representing the start/rez parameter passed to the object on creation (returns 0 if rezzed by an agent).
- `string` [`llGetStartString`](/functions/llGetStartString/) `()`: Returns the initialization string passed to the object's root prim on rez with llRezObjectWithParams (via REZ_PARAM_STRING; returns an empty string if rezzed by an agent).
- `void` [`llDie`](/functions/llDie/) `()`: Deletes the entire object containing the script (the object does not go to inventory). Use llBreakLink first to delete only a single prim.
- `integer` [`llDerezObject`](/functions/llDerezObject/) `(key id, integer flags)`: Derezzes (deletes or returns) a targeted object in the region previously rezzed by a script in this linkset, returning TRUE on success or FALSE on failure.
- `void` [`llGodLikeRezObject`](/functions/llGodLikeRezObject/) `(key id, vector pos)`: Rezzes an object directly from a UUID specified by id at the position pos, provided the owner has the god-bit set.

## Additional

- Link functions take a link number or a [link constant](/constants/groups/Links/) (some take only [one link](/constants/groups/Link/))
- [`llGetObjectDetails`](/functions/llGetObjectDetails/) — `OBJECT_*` [details](/constants/groups/ObjectDetailsParam/) of any object by key
- [`llRezObjectWithParams`](/functions/llRezObjectWithParams/) — `REZ_*` [parameters](/constants/groups/RezParam/) and [flags](/constants/groups/RezFlag/)
- [`llDerezObject`](/functions/llDerezObject/) — [derez modes](/constants/groups/DerezMode/)
  - [`DEREZ_DIE`](/constants/DEREZ_DIE/) — immediately delete (kill) the object

## Link numbers

Constant groups: [Link](/constants/groups/Link/) (2), [Links](/constants/groups/Links/) (5)

See also: [Guide: working with link numbers](/guides/link-numbers/), [Guide: linkset resources (reusable prims)](/guides/link-numbers/#linkset-resources)

## The object as a whole

Constant groups: [ObjectDetailsParam](/constants/groups/ObjectDetailsParam/) (56)

See also: [Object Target](/categories/object/)

## Rezzing objects

Constant groups: [RezParam](/constants/groups/RezParam/) (13), [RezFlag](/constants/groups/RezFlag/) (8), [DerezMode](/constants/groups/DerezMode/) (3)

See also: [Rez](/categories/rez/), [LSL Rez (Second Life Wiki)](https://wiki.secondlife.com/wiki/Category:LSL_Rez), [Script library: rezzers (Second Life Wiki)](https://wiki.secondlife.com/wiki/CatRezzers)

## Related

See also: [Linkset Target](/categories/linkset/), [Prims](/features/prims/), [Inventory](/features/inventory/)

## Related features

- [Prims](/features/prims/)
- [Physics](/features/physics/)
- [Avatars](/features/avatar/)

## Categories

- [Linkset Target](/categories/linkset/)
- [Object Target](/categories/object/)
- [Rez](/categories/rez/)

## On the Second Life Wiki

- [LSL Link](https://wiki.secondlife.com/wiki/Category:LSL_Link)

---

From lsl.dev: https://lsl.dev/features/linkset/
