Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Linking Hell

blaze Spinnaker
1/2 Serious
Join date: 12 Aug 2004
Posts: 5,898
09-04-2004 06:38
I am in linking hell.

I have 60+ objects and very tedious to be linking them everytime I need to delink in order to make positional changes.

I tried grouping a set of objects together and then linking the groups together, but the link order becomes very disruptive.

Is there a smoother way of linking groups of objects to gether and getting a straightforward link number order? Or should I change my code to handle the fact that the root primitive of each group becomes all the lower order numbers.
Maximus Zander
Registered User
Join date: 30 Apr 2004
Posts: 55
09-06-2004 07:39
You have to play around in the dirt.
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
09-07-2004 07:41
SL doesn't have hierarchical linking (yet *hope*hope*). All objects in a link set have the root primitive as a parent.

So, sadly, you can't create groups of objects in a link set, and if you relink, all your link numbers will get messed up.

You can make your life easier by using constants for link numbers, ie:
CODE
//links
integer BUTTON_1 4;
integer BUTTON_2 7;
etc

or
CODE
//links
list lButtons = [ 4, 7, ...];

and having this in your main script:
CODE
touch_start(integer n)
{
if (nDebugging) llSay(0, (string)llDetectedLinkNumber(0) + " was touched");
}


[edit: oh, you know you can de-link one child by turning on "select individual" in the edit window, choosing the child then CTRL-SHIFT-L'ing, right? You link numbers will still get re-orgainzed on you though]
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Ezhar Fairlight
professional slacker
Join date: 30 Jun 2003
Posts: 310
09-07-2004 09:17
You can also name each child prim to include it's desired link number. Then you can have a script link them for you in the right order (requires you to click to confirm linking permission once).

Or better yet, you name each prim by function, like "forward_button", "buy_button", "xytext4". Then at startup loop through all child prims and create an index of those names and their corresponding link numbers. Link order no longer matters as long as you recreate this index each time you relink the whole object. You then access your child prims by looking up their number on your index. Of course this is slower than fixed numbers (and memory consuming at 60 prims), but more flexible and much more comfortable.

Untested "dry" coding:
CODE

list gPrims; // strided list with pairs of: string name, integer linknumber

// creates an index of all prims in the link set with name and linknumber
CreateIndex() {
integer num_prims = llGetNumberOfPrims();
integer i;

gPrims = []; // clear list
for (i = 1; i <= num_prims; i++) gPrims += [llGetLinkName(i), i]; // index each prim
}

// retrieves the link number for a named prim in the set
integer PrimNumber(string name) {
return llList2Integer(gPrims, llListFindList(gPrims, [name]) + 1); // find the name and return the matching link number
}

default {
state_entry() {
CreateIndex(); // required at startup or whenever the link set changes

// now you can access each prim by name, like so:
llMessageLinked(PrimNumber("forward_button"), 0, "light up", NULL_KEY);

// or so:
llSetLinkAlpha(PrimNumber("door"), 0.0, ALL_SIDES);
}

changed(integer change) {
// note that this is also triggered when an AV sits on the object
if (change & CHANGED_LINK) CreateIndex(); // reindex when links changed
}
}


This could use some handling for prim names that weren't found in the list, but you get the idea.
_____________________