Difference between revisions of "No sensor"

From Second Life Wiki
Jump to navigation Jump to search
m
(fix variable name mismatch in code snippet)
Line 36: Line 36:
     if(data == [])
     if(data == [])
         return 0;
         return 0;
     return llVecDist(llList2Vector(data, 0), llGetPos()) <= dist;
     return llVecDist(llList2Vector(data, 0), llGetPos()) <= distance;
}</lsl>
}</lsl>
|also_header
|also_header

Revision as of 07:42, 15 September 2012

Description

Event: no_sensor( ){ ; }

Result of a call to llSensor or llSensorRepeat.


Caveats

  • sensor/no_sensor are not always the best solution:
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>//List all avatars in range. default {

    on_rez(integer i) {
         llSensor("", "", AGENT, 100000, 10000);
    }
    sensor(integer num) {
         integer i = 0;
         do {
              llOwnerSay(llDetectedName(i) + " is " + (string)llVecDist(llGetPos(), llDetectedPos(i)) + "m away.");
         }while(++i < num);
    }
    no_sensor() {
         llOwnerSay("No avatars in range.");
    }

}</lsl>

Useful Snippets

<lsl>//An alternative solution for find out if a user is not in range //No sensor is used so the above caveat doesn't apply.

integer InRange(key uuid, float distance) {

   list data = llGetObjectDetails(uuid, [OBJECT_POS]);
   if(data == [])
       return 0;
   return llVecDist(llList2Vector(data, 0), llGetPos()) <= distance;

}</lsl>

See Also

Functions

•  llSensor
•  llSensorRepeat

Deep Notes

Issues

All Issues

~ Search JIRA for related Issues
   llSensorRepeat not triggering no_sensor unless a sensor event handler is present

Signature

event void no_sensor(  );