Don't click here unless you want to be banned.

LSL Wiki : llDetectedKey

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl411.us.archive.org
key llDetectedKey(integer number)

Returns the key of detected object number (returns NULL_KEY if number is not valid sensed object).

Note: The llDetected* functions will only return a meaningful value in the collision(), collision_start(), collision_end(), sensor(), touch(), touch_start(), or touch_end() events.

Q: Is this a 0-based or 1-based index?
A: 0-based; This function starts counting at 0. -Chris

Example:
// By James Benedek
// llDetectedKey and llGetOwner Example.
default {
       collision_start(integer num_detected)
          {
           if (llDetectedKey(0) == llGetOwner())
           {
             llSay(0,"Hi, Owner!!!");
          }
           else
          {
           llSay(0,"YOU ARE NOT MY OWNER!");
    }
}
}

// Alternate example by Wouter Hobble
// llDetectedKey if there might be multiple keys detected.
default
{
   collision(integer num_detected)
   {
        integer i = 0;
        while ( i < num_detected)   // Shout something for every key detected.
        {
            llShout(0, "Colliding Key: " + llDetectedKey(i));
            ++i;
        }
   }
}


This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Detection | Sensors
Comments [Hide comments/form]
Can we have an example!?
-- Turnni1 (2007-01-08 04:43:09)
Yes, I am a bit confused by this as well. An example would be a good thing to have.
-- cache-mtc-ac13.proxy.aol.com (2007-05-05 16:29:43)
partial code to be used in a for loop, say

float objMass = llGetObjectMass( llDetectedKey(i) );
-- SimonRaven (2007-06-04 14:54:54)
Drop this in a prim and see what happens. -

key user;

default
{
state_entry()
{

}

touch_start(integer total_number)
{
user = llDetectedName(0);
llSay(0,user);
}
}
-- 88-104-219-105.dynamic.dsl.as9105.com (2007-08-30 13:20:18)
Attach a comment to this page: