Difference between revisions of "No sensor"

From Second Life Wiki
Jump to navigation Jump to search
(Added Example)
m (Replaced old <LSL> block with <source lang="lsl2">)
 
(15 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{LSL_Event|event_id=14|event_delay|event=no_sensor|event_desc=Result of the {{LSLG|llSensor}} library function call|constants|spec|caveats|examples|
{{Issues/SVC-2409}}{{LSL_Event
<pre>
|event_id=14
<pre>
|event_delay
//List all avatars in range.
|event=no_sensor
default {
|event_desc=Result of a call to [[llSensor]] or [[llSensorRepeat]].
     on_rez(integer i) {
|constants
           llSensor("", "", AGENT, 100000, 10000);
|spec
|caveats=
*sensor/no_sensor are not always the best solution:
**To determine if something is in/out of range is overkill. For this situation use: [[llGetObjectDetails]] as you will see in the [[#Useful Snippets|Useful&nbsp;Snippets]] section.
**To determine if an avatar is in the region, try [[llGetAgentSize]]
|examples=
<source lang="lsl2">//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 num) {
     sensor(integer number_detected)  
    {
           integer i = 0;
           integer i = 0;
           while (i < num) {
           do
               llOwnerSay(llDetectedName(i) + " is " + (string)llVecDist(llGetPos(), llDetectedPos(i)) + "m away.");
          {
              i++;
               llOwnerSay(llDetectedName(i) + " is " + (string) llVecDist(llGetPos(), llDetectedPos(i) ) + "m away.");
           }
           }
          while(++i < number_detected);
     }
     }
     no_sensor() {
     no_sensor()  
    {
           llOwnerSay("No avatars in range.");
           llOwnerSay("No avatars in range.");
     }
     }
}
}
</pre>
</source>


helpers
|helpers=
|also_header|also_events|also_functions=*{{LSLG|llSensor}}
<source lang="lsl2">//An alternative solution for find out if a user is not in range
*{{LSLG|llSensorRepeat}}|also_articles|also_footer
//No sensor is used so the above caveat doesn't apply.
|notes|mode|deprecated|cat1=Sensor
 
integer InRange(key uuid, float distance)
{
    list data = llGetObjectDetails(uuid, [OBJECT_POS]);
    if(data == [])
        return 0;
    return llVecDist(llList2Vector(data, 0), llGetPos()) <= distance;
}</source>
|also_header
|also_events
|also_functions={{LSL DefineRow||[[llSensor]]}}
{{LSL DefineRow||[[llSensorRepeat]]}}
|also_articles
|also_footer
|notes
|mode
|bugs={{LSL Bug|SVC-2409|llSensorRepeat not triggering no_sensor unless a sensor event handler is present}}
|deprecated
|cat1=Sensor
|cat2
|cat2
|cat3
|cat3
|cat4}}
|cat4
}}

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