Difference between revisions of "No sensor"

From Second Life Wiki
Jump to: navigation, search
m (use preferred 'AGENT_BY_LEGACY_NAME')
m (Replaced old <LSL> block with <source lang="lsl2">)
 
Line 11: Line 11:
 
**To determine if an avatar is in the region, try [[llGetAgentSize]]
 
**To determine if an avatar is in the region, try [[llGetAgentSize]]
 
|examples=
 
|examples=
<lsl>//List all avatars in range.
+
<source lang="lsl2">//List all avatars in range.
 
default  
 
default  
 
{
 
{
Line 32: Line 32:
 
     }
 
     }
 
}
 
}
</lsl>
+
</source>
  
 
|helpers=
 
|helpers=
<lsl>//An alternative solution for find out if a user is not in range
+
<source lang="lsl2">//An alternative solution for find out if a user is not in range
 
//No sensor is used so the above caveat doesn't apply.
 
//No sensor is used so the above caveat doesn't apply.
  
Line 44: Line 44:
 
         return 0;
 
         return 0;
 
     return llVecDist(llList2Vector(data, 0), llGetPos()) <= distance;
 
     return llVecDist(llList2Vector(data, 0), llGetPos()) <= distance;
}</lsl>
+
}</source>
 
|also_header
 
|also_header
 
|also_events
 
|also_events

Latest revision as of 01:15, 22 January 2015

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

//List all avatars in range.
default 
{
     on_rez(integer i) 
     {
          llSensor("", "", AGENT_BY_LEGACY_NAME, 96.0, PI);   // Detect any avatars within a 96 metre radius sphere
     }
     sensor(integer number_detected) 
     {
          integer i = 0;
          do 
          {
               llOwnerSay(llDetectedName(i) + " is " + (string) llVecDist(llGetPos(), llDetectedPos(i) ) + "m away.");
          }
          while(++i < number_detected);
     }
     no_sensor() 
     {
          llOwnerSay("No avatars in range.");
     }
}

Useful Snippets

//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;
}

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(  );