LlCreateLink

De DigiWiki.

// 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);
    }
}

Useful Snippets

// 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;
        }
    }
}
Outils personnels
  • Cette page a été consultée 756 fois.
donate
Google Ads