llCreateLink(key target, integer parent)
Attempts to
link the
object containing the
script and
target (requires that
permission PERMISSION_CHANGE_LINKS be set). If
parent == TRUE, the object
calling this
function will be the parent
prim of the new link set, and the target prim will become that parent's first
child (inserted before any children the parent might have already had).
Notes:
- This function delays the script for 1 second.
- Attached (worn) objects cannot be linked/unlinked.
- Attempts to link avatars to an object will fail with the message "Link failed -- avatar sitting on an object being linked."
The
target doesn't require any
script permission at all but does require that both objects'
owners be the same and each object has
modify permission.
Once the
target has been linked, its
changed event will be triggered with
CHANGED_LINK. The target will then also be able to receive
link_message events.
Q: What happens if the target is itself a linked object? Do links form trees, or are all the children of the target treated as children of the current object?
A: No, links are not trees. When one object links another, the new prims are added in the order in which they were added to the original object. Suppose we have Object A, consisting of three prims, [A1, A2, A3], and Object B, consisting of [B1, B2, B3]. Upon linking, the new object's link order would be [A1, B1, A2, A3, B2, B3]. This is the case with both linking via llCreateLink and the editing tools.
A: This may have changed recently. Currently, it appears that when linking two sets like those above, the resulting link-order will be [A1, B1, B2, B3, A2, A3], or more generally, [A1, (set of B in order), (rest of A in order) ].
Q: So is there a way to link two objects, with a resulting object's link order of [A1, A2, A3, B1, B2, B3]?
A: Not directly. Not only can you not specify where prims will end up in the resulting object, but you also can't selectively set a prim's position in the linkset. To accomplish this, you'd have to either break all links in the second object (and link its prims individually), or link it, delinking and relinking them individually. This second option is likely better, despite the extra step, as it could be more easily automated, and doesn't necessarily require the second object contain any scripts at all.
To
break a link, use
llBreakLink. To break
all links, use
llBreakAllLinks.
Functions |
Link