Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llDetectedLinkNumber help Please!

Trey Harris
Registered User
Join date: 28 Mar 2006
Posts: 8
11-18-2006 14:09
Is there an easy way to get the link_number of a prim once it has been linked? So I can later use code to address just that prim and make it invisible? Thanks any help would be greatly appreciated!
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
11-18-2006 14:47
DetectedLinkNumber should work nicely there, just like you mention it.
CODE

default {

touch_start( integer Contacts ) {

llOwnerSay( "prim no " + (string)llDetectedLinkNumber(0) );
}
}

put it in the root prim, then click the prim you want to know the number of.
Trey Harris
Registered User
Join date: 28 Mar 2006
Posts: 8
thanks
11-18-2006 15:04
Ok thank you!! was just not sure how to use it! Could not find an example!
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-18-2006 19:11
I like so many am still learning LSL. Kind of think we will always be learning something new, no matter how advanced. To me the wiki really wasn't all that clear on passing touchs and Joannah's little script snippet said it all so simply.

I have just been playing with it and added another trick into it also. For the ones that follow us and do a search for DetectedLinkNumber and come across this thread:



A person could put this script into different prims and get it to change it's color and say the color:



CODE

default {
touch_start( integer n ) {
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <1, 0, 0>, 0.6]);
llOwnerSay("My color is red");
}
}


But you would have to put the script in each prim and could not use that in a linkset. It would only affect the root prim, no matter which prim you touched. So you can do this instead. Link four prim and put this in the root prim:

CODE


default {
touch_start( integer n ) {
integer child = llDetectedLinkNumber( 0);
string childname = llGetLinkName( child );
if(child == 2){
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <1, 0, 0>, 0.6]);
llOwnerSay( "Child Prim name: " + childname +
", link #" + (string)child + " touched." );
}
if(child == 3){
color = <0, 0, 1>;
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0, 0, 1>, 0.6]);
llOwnerSay( "Child Prim name: " + childname +
", link #" + (string)child + " touched." );
}
if(child == 4){
color = <0, 1, 0>;
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <0, 1, 0>, 0.6]);
llOwnerSay( "Child Prim name: " + childname +
", link #" + (string)child + " touched." );
}
}
}


Now you have saved the sim several scripts and could also use that in a hud. But you can also save some script memory by creating your own functions. If you look closely, you can see that you can even place one user defined function inside another user defined function. Same setup; create a linkset of 4 prim and place in root:

CODE

integer child;
string childname;
vector color;
say(){
llOwnerSay( "Child Prim name: " + childname +
", link #" + (string)child + " touched." );
}

params(){
llSetPrimitiveParams([PRIM_COLOR, 4, color, 0.6]);
say();
}

default {
touch_start( integer n ) {
child = llDetectedLinkNumber( 0);
childname = llGetLinkName( child );
if(child == 2){
color = <1, 0, 0>;
params();
}
if(child == 3){
color = <0, 0, 1>;
params();
}

if(child == 4){
color = <0, 1, 0>;
params();
}
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
11-18-2006 19:38
From: Jesse Barnett
A person could put this script into different prims and get it to change it's color and say the color:



CODE

default {
touch_start( integer n ) {
llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <1, 0, 0>, 0.6]);
llOwnerSay("My color is red");
}
}


But you would have to put the script in each prim and could not use that in a linkset.

Try this ^^
CODE

default
{
touch_start(integer total_number)
{
llSetLinkColor( llDetectedLinkNumber(0), <1, 0, 0>, ALL_SIDES );
llOwnerSay( "Look ma, am red \\o/" );
}
}

sadly, the ability to remotely alter a prim only works for colour and alpha value :/
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-18-2006 19:43
AH cool!!!!! Another new trick. I sooooooo love new tricks.

But in the demo I was just trying to change the color of the root prim. I just added the first script as an after thought.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Nynthan Folsom
Registered User
Join date: 29 Aug 2006
Posts: 70
12-02-2006 00:59
Am I mistaken or aren't all linked children placed at the lowest index positions?

For instance if you call llCreateLink(some_key, TRUE), that would insert the prim referenced by some_key into the link set at position 2 (1 being the root prim).

In fact, I'm pretty sure that objects are linked in the reverse order in which they are selected.