LlCreateLink
Looking for the current API? Open the llCreateLink reference →
Wiki description
Attempt to link the script's object with
target.Function notes
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
- If
targetis 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
targetare not modifiable or of different owners, then an error is shouted on DEBUG_CHANNEL. - If the the parent object and
targetare too far apart they will fail to link.- The maximum distance is further explained here: Linkability Rules
- This function silently fails if called from a script inside an attachment.
Examples
// Rez an 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);
}
}Helper functions
// child prim key
key kChild = NULL_KEY;
integer bLink = TRUE; // we suppose this script is on a linked object
default
{
state_entry()
{
// get the permission to change the link
llRequestPermissions(llGetOwner(), PERMISSION_CHANGE_LINKS);
// get the child key
kChild = llGetLinkKey(2);
}
touch_start(integer nTotalCliquor)
{
if (bLink)
{
// break all my links, wait 1.5 sec
llBreakAllLinks();
llSleep(1.5);
// i'm unlinked
llSay(0, "Unlinked, click to link");
bLink = FALSE;
}
else
{
// redo my link
llCreateLink(kChild, TRUE);
llSleep(1.5);
// i'm linked
llSay(0, "Linked, click to unlink");
bLink = TRUE;
}
}
} See also: functions
See also: events
See also: articles
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Template:LSL Function/permission
Original shared helper source (conditional wiki logic is not evaluated)
{{#if:
{{{{#if:{{#var:DEBUG_CHANNEL}}||:DEBUG_CHANNEL}}|}}
{{#vardefine:header_footnote|{{#var:header_footnote}}{{#if:{{{1|<noinclude>*</noinclude>}}}|To run this function the script must request the [[{{{1}}}]] {{#if:{{{2|}}}|or [[{{{2}}}]]}} permission with [[llRequestPermissions]]{{#ifeq:{{{grant|anyone}}}|anyone|| and it must be granted by {{{grant|anyone}}}}}.}}}}
{{#vardefine:caveats|{{#var:caveats}}{{#if:{{{1|<noinclude>*</noinclude>}}}|{{PBR}}
<div style="border: 1px dotted rgba(0,0,0,0.5);">{{Collapsible_Table/Simple|title=<h5 style="margin:0;">Permissions</h5>|table-style=width:100%;|autocollapse=*|content={{!}}<div>
* Do not depend upon the auto-grant status of permissions. '''Always''' use the [[run_time_permissions]] event.
* If the script lacks {{#if:{{{2|}}}|both the permissions [[{{{1}}}]] and [[{{{2}}}]]|the permission [[{{{1}}}]]}}, the script will shout an error on {{#var:DEBUG_CHANNEL}} and the operation fails (but the script continues to run).{{#ifeq:{{{grant|anyone<noinclude>*</noinclude>}}}|anyone||
* If [[{{{1}}}]] {{#if:{{{2|}}}|or [[{{{2}}}]]}} is granted by anyone other than {{{grant|anyone}}}, then when the function is called an error will be shouted on {{#var:DEBUG_CHANNEL}}.}}
{{{caveats|}}}{{LSL Function/permission/caveat switch|{{{1}}}}}{{#if:{{{2|}}}|{{LSL Function/permission/caveat switch|{{{2}}}}}}}</div>}}</div>}}}}
{{#vardefine:also_events|{{#var:also_events}}
{{LSL DefineRow||[[run_time_permissions]]|Permission receiving event}}}}
{{#vardefine:also_functions|{{#var:also_functions}}
{{LSL DefineRow||[[llGetPermissions]]|Get the permissions granted}}
{{LSL DefineRow||[[llGetPermissionsKey]]|Get the agent who granted permissions}}
{{LSL DefineRow||[[llRequestPermissions]]|Request permissions}}}}
{{#vardefine:also_articles|{{#var:also_articles}}
{{LSL DefineRow||[[:Category:LSL Permissions/Script|Script permissions]]|}}}}
<includeonly>{{#if:{{{nc|}}}||{{#vardefine:hidden-text|{{#var:hidden-text}}
{{#if:{{#pos:{{#var:moded}}|r}}{{#pos:{{#var:moded}}|u}}||[[Category:LSL Requires Permissions]]}}
}}}}</includeonly>
}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|header_footnote}}
|-
{{VarPair|caveats}}
|-
{{VarPairTable|also_events}}
|-
{{VarPairTable|also_functions}}
|-
{{VarPairTable|also_articles}}
|}
</noinclude>Original shared helper source (conditional wiki logic is not evaluated)
<noinclude>{{Multi-lang|category=LSL}}</noinclude>{{LSL Injection Test}}{{#if:
{{#vardefine:p_{{{1|none}}}_desc|{{#if:{{{object|}}}|[[object]]|[[prim]]}} {{HoverLink|UUID|Universally Unique Identifier}} {{#if:{{{sim|}}}|that is in the same [[region]] {{#switch:{{{sim|}}}|*=|#default={{{sim|}}}}}
}}}}
{{#vardefine:p_{{{1|none}}}_hover|{{#if:{{{object|}}}|object|prim}} UUID {{#if:{{{sim|}}}|that is in the same region {{#switch:{{{sim|}}}|*=|#default={{{sim|}}}}}
}}}}
}}<noinclude>
{| {{Prettytable}}
|-{{Hl2}}
!var
!value
|-
|desc
|{{#var:p_{{{1|none}}}_desc}}
|-
|hover
|{{#var:p_{{{1|none}}}_hover}}
|}
</noinclude>Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.