Naskiff Posted February 19, 2018 Share Posted February 19, 2018 (edited) 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 February 19, 2018 by Naskiff Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 19, 2018 Share Posted February 19, 2018 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. 1 Link to comment Share on other sites More sharing options...
Naskiff Posted February 19, 2018 Author Share Posted February 19, 2018 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! Link to comment Share on other sites More sharing options...
Ruthven Ravenhurst Posted February 19, 2018 Share Posted February 19, 2018 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 More sharing options...
Naskiff Posted February 19, 2018 Author Share Posted February 19, 2018 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. Link to comment Share on other sites More sharing options...
Love Zhaoying Posted February 19, 2018 Share Posted February 19, 2018 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). Link to comment Share on other sites More sharing options...
Naskiff Posted February 19, 2018 Author Share Posted February 19, 2018 (edited) 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 February 19, 2018 by Naskiff Link to comment Share on other sites More sharing options...
animats Posted February 28, 2018 Share Posted February 28, 2018 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 More sharing options...
Recommended Posts
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