Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llDetectedLinkNumber

Altern8 McMillan
Registered User
Join date: 27 Mar 2007
Posts: 36
08-12-2007 09:39
Hi there,
just wondering about this function. Well, more about the param to be passed. It says

integer llDetectedLinkNumber(integer number)

Is there another value that makes sense besides passing 0? Anyone figured this out? Cuz all the wikis do not say anything about it.

Thx and greetz

A8
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
08-12-2007 09:54
From: Altern8 McMillan
Is there another value that makes sense besides passing 0?
Depends how the "detecting" happened. For touches and collisions, usually the 0th thing detected is the only one that matters. For sensors, though, you might have sixteen Detected guys to choose from. (Edit: hehehe... exactly how one would go about a sensor event triggering something to check with llDetectedLinkNumber() escapes me at the moment... so I guess I see the point. :o )
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
08-12-2007 17:21
I think I read that sometimes using object names, by naming the parts, instead of link numbers is the way to go. I have no idea really...
Just disregard if inappropriate.
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Altern8 McMillan
Registered User
Join date: 27 Mar 2007
Posts: 36
08-12-2007 22:48
From: someone
I think I read that sometimes using object names, by naming the parts, instead of link numbers is the way to go. I have no idea really...

I haven't tried it yet, but if u name an object it could either be a string (name) or a key (uuid), but the function expects an integer to be passed. If u recap where u read it, would be some great help.

greetz

a8
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
08-13-2007 04:17
Umm... maybe it would help to know what the script is actually trying to do. If the objective is to run through all the prims in the linkset, for example, and color or texture them, then llGetLinkName() could be useful. In fact, the script can do that at startup (and again whenever CHANGED_LINK is raised), for all linked prims from 1 (the root) to llGetNumberOfPrims, keeping list(s) of which link numbers have which names.

But, there's really no mystery about the argument to llDetectedLinkNumber(). For starters, it will only work inside event handlers where the llDetected- functions have value, like touch and collision (and theoretically sensor, but in practice, I don't think there's a way for a sensor to detect a single prim in a linkset anyway). And, unless you have multiple simultaneous touches or collisions (which almost never happens), the num_detected parameter passed to that event handler will always be 1, so only llDetectedLinkNumber(0) will be defined.

Maybe this is just restating the obvious, in which case a more detailed statement of the question might help.
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
08-13-2007 04:26
From: Altern8 McMillan
I haven't tried it yet, but if u name an object it could either be a string (name) or a key (uuid), but the function expects an integer to be passed. If u recap where u read it, would be some great help.

greetz

a8


I think he means name the child prim and use an llMessageLinked() / link_message setup instead.

llMessageLinked(LINK_ROOT, 0, llGetObjectName(),llDetectedKey(0));
would pass the name of the prim and key of the detected agent back to root.

llDetectedLinkNumber(integer number) has the advantage of not needing a script in each child prim in order to tell which once was touched, but has the disadvantage of needing to keep track of which prim is which.
Altern8 McMillan
Registered User
Join date: 27 Mar 2007
Posts: 36
08-13-2007 12:03
Thx a lot for all the answers, I'd love to post a script to that, but there is no script I could refer to. I was only fooling around with llPassTouches and wondered why the integer param of llDetectedLinkNumber always has to be 0 and if anyone could imagine another possible integer value to be passed in some other cases, which I am maybe not thinking about right now.

But the discussion showed so far that no one has passed another integer value with llDetectedLinkNumber than 0 so far. I am aware of all the other possibilities like llGetLinkName and even about the advantages of llDetectedLinkNumber . But in the end of the day there must be a reason to pass an integer value. Cuz if it is always 0 to be passed, why, don't laugh now, should it be implemented into the language by the Lindens to have the possibility to pass an integer value anyway. They just could have implemented the function without an integer to be passed. But I guess the more experienced LSL developers of u will tell me now, don't take everything to serious, some things are just like they are, just use them and be happy about it. :)

greetz

a8
Kidd Krasner
Registered User
Join date: 1 Jan 2007
Posts: 1,938
08-13-2007 17:23
Imagine having a target comprising several prims, and a rapid fire gun shooting at it. You need to know which prim was hit to determine the score. It's conceivable that you could have multiple collision events on the target before the collision event handler gets called. In that situation, you have to iterate over all the collision events, passing a different number each time to llDetectedLink.
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
08-14-2007 07:22
If I make something with e.g. buttons (like a HUD or Vendor), I name the buttons logically (e.g. "BTN:INFO" or "NEXT";) and use llGetLinkName(llDetectedLinkNumber(0)) so I don't have to care about the link order.

A minor detail: touch events return the number of agents touching. In almost all cases this will be 1 (especially if you only use touch_start), but I guess in a really busy sim with a lot of ppl clicking a e.g. dancefloor, and some lag, multiple agents could be clicking the object in same event call. In those cases, you'll want to loop thru the number of agents like so:

touch_start(integer agentCount)
{
while (agentCount)
{
--agentCount;
if (llGetLinkName(llDetectedLinkNumber(agentCount)) == "BTN:INFO";)
{
llGiveInventory(llDetectedKey(agentCount), "Info notecard";);
}
}
}
(quote to see indented)

I know it's rare, but it explains the purpose of the parameter to llDetectedLinkNumber and related functions.

Lyn
Simil Miles
Creator
Join date: 1 Mar 2007
Posts: 300
08-14-2007 09:31
Use a FOR loop to go through the total number of detected.
_____________________
UnConWTech @ Flo (144, 84, 224) http://unconwtech.free.fr

SL books http://astore.amazon.com/secondlife-sl-20/

Need a beta tester for quality assurance ?
Need a translator for English, French, Spanish ?