Difference between revisions of "No sensor"

From Second Life Wiki
Jump to navigation Jump to search
m (woops)
m
Line 31: Line 31:
integer InRange(key uuid, float distance)
integer InRange(key uuid, float distance)
{
{
     list data = llGetObjectDetails(user, [OBJECT_POS]);
     list data = llGetObjectDetails(uuid, [OBJECT_POS]);
     if(data == [])
     if(data == [])
         return 0;
         return 0;

Revision as of 12:51, 25 May 2008

Description

Event: no_sensor( ){ ; }

Result of a call to llSensor or llSensorRepeat.


Caveats

  • The script must have a sensor event, without it no_sensor will not be triggered. An empty sensor event is enough to satisfy this condition and cause no_sensor to be triggered.
    • Using a sensor this way is not the easiest way of finding out if a user is not around. If determining if the user is in the sim is the goal then llGetAgentSize is a good alternative, another solution is to use llGetObjectDetails as you will see in the Useful Snippets section.
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()) <= dist;

}</lsl>

See Also

Functions

•  llSensor
•  llSensorRepeat

Deep Notes

Signature

event void no_sensor(  );