Jump to content

Sensor returns NULL key. (Solved)


Naskiff
 Share

You are about to reply to a thread that has been inactive for 2220 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I am trying to scan a nearby scripted object to get its object name. I figure getting its key would be a good start... Could someone please explain why this sensor keeps returning a NULL key when it detects an object?

"I detect 00000000-0000-0000-0000-000000000000"

 

What I'm actually trying to accomplish is, I want to wear this sensor. When I walk into a small, non-physical item that has a particular name, it will change my hover height to a predetermined value to make it seem like I'm standing on it normally.

key id;
default
{
    state_entry()
    {
        llSensorRepeat("","",SCRIPTED,1,PI,2);
        llOwnerSay("beep");
    }
    sensor(integer num_detect)
    {
        id = llDetectedKey(num_detect);
        llOwnerSay("I detect "+(string)id);
    }
    no_sensor()
    {
        llOwnerSay("no detect");
    }
}

 

Edited by Naskiff
Link to comment
Share on other sites

Also, num_detect is the number of detected results. Like lists, you need to start with index 0 for the first item, so you would want to use

id = llDetectedKey(0);

or better  yet, run a loop

sensor(num_detect)
{
	integer index = 0;
	while(index < num_detect)
    {
       key id = llDetectedKey(index);
       llOwnerSay("I detect: " + (string)id);
       index++;
    }
}

 

Link to comment
Share on other sites

I am trying to detect non-physical objects, not myself. ^^ I want the script to bump me up a little when I "collide" with a certain non-physical object.   Without the script, I just walk through that object. But yes it's only intended to be used by myself.

Edited by Naskiff
Link to comment
Share on other sites

  • 2 weeks later...
sensor(integer num_detect)
    {
        id = llDetectedKey(num_detect);

"sensor" is called with the number of detected objects (probably 1) and the objects are numbered from 0. So you detect one object, and it's #0, but you're asking for #1, which gives you a NULL_KEY.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2220 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...