From Second Life Wiki
(Redirected from
LSL llCreateLink)
CreateLink
llCreateLink
Description
Function: llCreateLink( key target, integer parent );
Attempt to link the script's object with target.
| • key
| target
| –
| A prim in the same region.
|
|
| • integer
| parent
| –
| If FALSE, then target becomes the root. If TRUE, then the script's object becomes the root.
|
|
Requires the PERMISSION_CHANGE_LINKS permission, granted by the owner, to run.
target must be modifiable and have the same owner.
This object must also be modifiable.
Specification
The prims for the child object (target if parent is TRUE, script's object if parent is FALSE) are inserted into the parent object's link set starting at link number 2. For example, if the link order for the parent object is A1, A2, A3 and the link order of the child object is B1, B2, B3, then the link order of the resulting object will be A1, B1, B2, B3, A2, A3.
Caveats
- This function causes the script to sleep for 1.0 seconds.
- Do not depend upon the auto-grant status of permissions. Always use the run_time_permissions event.
- If the script lacks the permission PERMISSION_CHANGE_LINKS, the script will shout an error on DEBUG_CHANNEL and the operation fails (but the script continues to run).
- If PERMISSION_CHANGE_LINKS is granted by anyone other then the owner then when the function is called an error will be shouted on DEBUG_CHANNEL.
- Once the PERMISSION_CHANGE_LINKS permission is granted there is no way to revoke it. The script will only loose the permission if it is reset or the object derezzed (deleted, detached, or taken).
- If target is not in the region, not a prim, or is attached to an avatar, an error is shouted on DEBUG_CHANNEL.
- If either the object or the target are not modifiable or of different owners, then an error is shouted on DEBUG_CHANNEL.
- If the the parent object and target are too far apart (based on their physical size), they will fail to link.
- This function silently fails if called from a script inside an attachment.
Examples
// Create a new object and link it as a child prim.
string ObjectName = "Object Name Here";
// NOTE: must be a name of an object in this object's inventory.
default
{
touch_start(integer count)
{
// When the object is touched, make sure we can do this before trying.
llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS);
}
run_time_permissions(integer perm)
{
// Only bother rezzing the object if will be able to link it.
if (perm & PERMISSION_CHANGE_LINKS)
llRezObject(ObjectName, llGetPos() + <0,0,0.5>, ZERO_VECTOR, llGetRot(), 0);
else
llOwnerSay("Sorry, we can't link.");
}
object_rez(key id)
{
// NOTE: under some conditions, this could fail to work.
// This is the parent object. Create a link to the newly-created child.
llCreateLink(id, TRUE);
}
}
See Also
Events
Functions
Articles