Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Few Questions On How llCreateLink and llBreakAllLinks

Ross Penucca
Super Rubik's User
Join date: 3 Jun 2008
Posts: 26
06-12-2008 14:45
Before I get into the function questions, I have a few important questions that could affect this whole thing: when a prim is rezzed, it is given a key, correct? And when two or more prims are linked together, the complex prim link collection is given a separate key, or the key of the parent/root prim? And when a complex prim link collection is UNLINKED, do the individual prims retain their ORIGINAL keys? I.E.: Prim A has a key of 10A70 and Prim B has a key of 10A71. I create a link between the two where Prim A is the parent/room prim, does this new link keep Prim A's key of 10A70? Or does the new link get it's own key, say, 10A72? THEN, when I unlink Prim A and Prim B, does Prim A's key go BACK to 10A70 and Prim B's key back to 10A71 or are they given completely NEW keys? Now, do all of these rules apply to llCreateLink AND llBreakAllLinks also or do they work differently? I suppose I could test this, but I wanted to ask here first, or at least, ask here AND test at the same time.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
06-12-2008 16:25
My understanding is that the linked object will simply have the key of the root prim, and that none of the prim keys will change during linking or unlinking. But why don't you simply test it?
Ross Penucca
Super Rubik's User
Join date: 3 Jun 2008
Posts: 26
06-12-2008 17:44
I did a little bit, I think. However, I couldn't get the modify permission to work correctly, probably because within the link, I have to send a link message to all of the children for modify requests, right? All linked prims have to have modifiability in order for any of them to be modified?
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
06-12-2008 19:18
While an instance of a prim exists in world, the key of that instance never changes. Just to clear things up, an object is a collection of prims, the root prim is a prim. The key of an object is really the key of the root prim. Regardless of how you link and unlink prims, the keys never change.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Ross Penucca
Super Rubik's User
Join date: 3 Jun 2008
Posts: 26
06-12-2008 23:25
Awesome, that works perfectly. While I'm thinking about it though, can you create links by grabbing a prim at a specific location? For instance, I want to link A to B, A's position is <1.0, 1.0, 1.0> and B's position is <2.0, 2.0, 2.0>. Could I tell A: "Be the parent of a prim by linking with the prim at location <2.0, 2.0, 2.0>?" If I could, then that would make my job a WHOLE lot easier then the method I have of this big first project and it would also allow for more interactivity from avatars.

EDIT: I found this in the SL wiki for llCreateLink:

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

This seems to use a basis of what I wanted to do. So according to this, I would have to rez the prim, in this case, B, then tell A to link to B's position from the rez. So this would be the only way to do it or could I just have A link to B's location with B having been rezzed before the start of A's script?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-13-2008 06:40
From: Ross Penucca
... could I just have A link to B's location with B having been rezzed before the start of A's script?
You can have A link to B if the script in A has B's key, which is easy if A rezzes B as in the sample script, but can be found in other ways (say, with a sensor scan run in A's script... or B may be scripted to announce its key on some channel to which A is listening... etc). Of course, B has to have the same owner as A, A must have PERMISSION_CHANGE_LINKS, the objects have to be modifiable and within linking distance for their sizes, and all that jazz.
_____________________
Archived for Your Protection
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
06-13-2008 10:27
From: Ross Penucca
Awesome, that works perfectly. While I'm thinking about it though, can you create links by grabbing a prim at a specific location? For instance, I want to link A to B, A's position is <1.0, 1.0, 1.0> and B's position is <2.0, 2.0, 2.0>. Could I tell A: "Be the parent of a prim by linking with the prim at location <2.0, 2.0, 2.0>?" If I could, then that would make my job a WHOLE lot easier then the method I have of this big first project and it would also allow for more interactivity from avatars.

If A is at <1,1,1> (with zero rotation so its axes are aligned with the world axes) and B is at <2,2,2>, then when you link B to A (A is the root), B will have local coordinates <2-1,2-1,2-1>=<1,1,1>. You can either position them like this before the link or move B after the link using llSetPos() or llSetLinkPrimitiveParams() from B, or llSetLinkPrimitiveParams() from A.

EDIT: Oh. Re-reading your question, I seethat's not what you are asking. A sensor would be the way to go. Move A as close to <2,2,2> as possible so you know B is one of the 16 closest objects, filter the sensor as specifically as you can, and then test which detected object is closest to <2,2,2>.
Ross Penucca
Super Rubik's User
Join date: 3 Jun 2008
Posts: 26
06-13-2008 11:38
Ah, a sensor, ok. So I would: send sensor out for specific locations, link those locations to the root prim, rotate along the root prim (center), then unlink. Then rinse and repeat as desired. See, I knew there was a way to do this, but I wasn't quite sure, thanks a bundle.