Jump to content
Naskiff

Sensor returns NULL key. (Solved)

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

Share this post


Link to post
Share on other sites

Try   llSensorRepeat("","",ACTIVE|SCRIPTED,1.0,PI,2.0);   Also, consider the possibility that your target object is more than 1.0m from the sensor.

  • Like 1

Share this post


Link to post
Share on other sites

It did not change the result, but I have found a solution.  I really don't understand why it changes anything, but I needed to add while(num_detect--) inside sensor().

Thank you for you time!

Share this post


Link to post
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++;
    }
}

 

Share this post


Link to post
Share on other sites

Indeed, I will do something to deal with multiple detections. I tend to start with something stripped out like this and build on top of it.  Thank you. :)

Share this post


Link to post
Share on other sites

Are you really scripting this to work only for you? You could use llGetOwnerKey() as the key parameter for llSensorRepeat(). That way, it only detects you (or the owner if you sell it).

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...