Difference between revisions of "User:Haravikk Mistral/Sensor/Types"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with '{{subst:LSL_Constants_Sensor}}')
 
 
Line 1: Line 1:
{{#if:||{{{!}} }}
{| class="sortable" {{Prettytable|style=}}
{{!}}- valign="top"
|-{{Hl2}}
{{!}}
!Constant
{{{!}} {{Prettytable|style=}}
!Description
{{!}}-{{Hl2}}
|-
! colspan="2" {{!}} ''' Flag Mask'''
|<code>AGENT</code>
! '''Description ([[llDetectedType]]())'''
|Avatars, optionally identified by their {{LSLGC|Avatar/Name|display name}}.
! '''Description ([[llSensor]]() and [[llSensorRepeat]]() mask)'''
|-
{{!}}-
|<code>AGENT_BY_LEGACY_NAME</code>
{{!}} {{#vardefine:AGENT|{{LSL Const|AGENT|integer|1|hex=0x1|c=Agents}}}}{{#var:AGENT}}
|Avatars, optionally identified by their {{LSLGC|Avatar/Name|legacy name}}.
{{!}} {{#var:value}}
|-
{{!}} {{#var:comment}}
|<code>AGENT_BY_USERNAME</code>
{{!}} DEPRECATED: Use AGENT_BY_LEGACY_NAME
|Avatars, optionally identified by their {{LSLGC|Avatar/Name|username}}.
{{!}}-
|-
{{!}} {{#vardefine:AGENT_BY_LEGACY_NAME|{{LSL Const|AGENT_BY_LEGACY_NAME|integer|1|hex=0x1|c=Agents}}}}{{#var:AGENT_BY_LEGACY_NAME}}
|<code>ACTIVE</code>
{{!}} {{#var:value}}
|Physical objects that are moving or objects containing an active script.
{{!}} {{#var:comment}}
|-
{{!}} This is used to find agents by {{LSLGC|Avatar/Name|legacy name}}.
|<code>PASSIVE</code>
{{!}}-
|Non-scripted or script is inactive and non-physical or, if physical, not moving.
{{!}} {{#vardefine:AGENT_BY_USERNAME|{{LSL Const|AGENT_BY_USERNAME|integer|16|hex=0x10|c=Agents}}}}{{#var:AGENT_BY_USERNAME}}
|-
{{!}} {{#var:value}}
|<code>SCRIPTED</code>
{{!}} {{#var:comment}}
|Objects that has any script, which is doing anything in simulator just now.
{{!}} This is used to find agents by {{LSLGC|Avatar/Name|username}}.
|-
{{!}}-
|<code>LAND</code>
{{!}} {{#vardefine:ACTIVE|{{LSL Const|ACTIVE|integer|2|hex=0x2|c=Physical tasks. (Physical objects & agents) }}}}{{#var:ACTIVE}}
|The simulator's ground segments (only supported by [[User:Haravikk_Mistral/LlCastRay|llCastRay]]()).
{{!}} {{#var:value}}
|}
{{!}} {{#var:comment}}
{{!}} Physical objects that are moving or objects containing an active script. Thus, it is using SL server resources now.
{{!}}-
{{!}} {{#vardefine:PASSIVE|{{LSL Const|PASSIVE|integer|4|hex=0x4|c=Non-physical objects.}}}}{{#var:PASSIVE}}
{{!}} {{#var:value}}
{{!}} {{#var:comment}}
{{!}} Non-scripted or script is inactive and non-physical or, if physical, not moving. Thus, it is not using SL server resources now.
{{!}}-
{{!}} {{#vardefine:SCRIPTED|{{LSL Const|SCRIPTED|integer|8|hex=0x8|c=Objects containing any active script.}}}}{{#var:SCRIPTED}}
{{!}} {{#var:value}}
{{!}} {{#var:comment}}
{{!}} Objects that has any script, which is doing anything in simulator just now.
{{!}}}
{{{!}} {{Prettytable}}
{{!}}-{{Hl2}}
!llDetectedType()
!Scripted
!Not Scripted
{{!}}-
! Physical
{{!}} 10 ({{#var:ACTIVE}}|{{#var:SCRIPTED}})
{{!}} 2 ({{#var:ACTIVE}})
{{!}}-
! Non-Physical
{{!}} 12 ({{#var:PASSIVE}}|{{#var:SCRIPTED}})
{{!}} 4 ({{#var:PASSIVE}})
{{!}}}
{{#if:||{{!}}} }}{{#if:
 
{{#vardefine:also_articles|{{#var:also_articles}}*[http://lslwiki.net/lslwiki/wakka.php?wakka=ObjectType Object Type]}}
 
{{#if:|
{{#vardefine:examples|{{#var:examples}}
'''Using [[llDetectedType]] in [[collision]] event:'''
<lsl>
integer type;
 
default
{
    state_entry()
    {
        llVolumeDetect(TRUE);
    }
    collision_start(integer detected)
    {
        type = llDetectedType(0);
        if(type == AGENT)// = 1
        {
            llSay(0, "This is impossible. Since there is no avatar who doesn't require the physical calculation.");
        }
        else if(type == ACTIVE)// = 2
        {
            llSay(0, "I have been struck by a physical object not containing any script.");
        }
        else if(type == PASSIVE)// = 4
        {
            llSay(0, "This is impossible. Non-physical objects cannot trigger this event.");
        }
        else if(type == SCRIPTED)// = 8
        {
            llSay(0, "This is impossible. Since there is no object which isn't physical nor non-physical.");
        }
        else if(type == 3)// AGENT & ACTIVE
        {
            llSay(0, "I have been struck by an avatar.");
        }
        else if(type == 10)// SCRIPTED & ACTIVE
        {
            llSay(0, "I have been struck by a phisical object containing any script.");
        }
        else if(type == 12)// SCRIPTED & PASSIVE
        {
            llSay(0, "This is impossible. Non-physical objects cannot trigger this event.");
        }
    }
}
</lsl>
'''Using [[llDetectedType]] in [[sensor]] event:'''
<lsl>
default
{
    touch_start(integer numberDetected)
    {
        llSensor("", "", ACTIVE | PASSIVE | AGENT, 20.0, PI); // activates the sensor.
    }
 
    sensor (integer numberDetected)
    {
        integer i = 0;
        while(i < numberDetected)
        {
            integer type = llDetectedType(i);
            string message;
            message += (string)i + ", " + llDetectedName(i) + ", ";
            list typeList;
            if(AGENT & type)
            {
                typeList += "AGENT";
            }
            if(ACTIVE & type)
            {
                typeList += "ACTIVE";
            }
            if(PASSIVE & type)
            {
                typeList += "PASSIVE";
            }
            if(SCRIPTED & type)
            {
                typeList += "SCRIPTED";
            }
            message += llDumpList2String(typeList, "|");
            llWhisper(0, message);
            i++;
        }
    }
    no_sensor()
    {
        // This is impossible if range = 20.0 and you are standing within 10m!
        llWhisper(0, "Nothing is near me at present.");
    }
}
</lsl>
'''Using filter in {{LSLGC|Sensor|llSensor*}} functions:'''
<lsl>
integer done;
 
tellit(integer detected)
{
    integer i = 0;
    while(i < detected)
    {
        integer type = llDetectedType(i);
        string message;
        llWhisper(0, (string)i + ", " + llDetectedName(i));
        i++;
    }
}
default
{
    touch_start(integer detected)
    {
        llWhisper(0, "AGENT");
        llSensor("", "", AGENT, 20.0, PI);
    }
    sensor(integer detected)
    {
        if(done == 0)
        {   
            tellit(detected);
            llWhisper(0, "ACTIVE");
            llSensor("", "", ACTIVE, 20.0, PI);
            ++done;
        }
        else if(done == 1)
        {
            tellit(detected);
            llWhisper(0, "AGENT|ACTIVE");
            llSensor("", "", AGENT | ACTIVE, 20.0, PI);
            ++done;
        }
        else if(done == 2)
        {
            tellit(detected);
            llWhisper(0, "PASSIVE");
            llSensor("", "", PASSIVE, 20.0, PI);
            ++done;
        }
        else if(done == 3)
        {   
            tellit(detected);
            llWhisper(0, "AGENT|PASSIVE");
            llSensor("", "", AGENT | PASSIVE, 20.0, PI);
            ++done;
        }
        else if(done == 4)
        {   
            tellit(detected);
            llWhisper(0, "ACTIVE|PASSIVE");
            llSensor("", "", ACTIVE | PASSIVE, 20.0, PI);
            ++done;
        }
        else if(done == 5)
        {   
            tellit(detected);
            llWhisper(0, "AGENT|ACTIVE|PASSIVE");
            llSensor("", "", AGENT | ACTIVE | PASSIVE, 20.0, PI);
            ++done;
        }
        else if(done == 6)
        {   
            tellit(detected);
            llWhisper(0, "SCRIPTED");
            llSensor("", "", SCRIPTED, 20.0, PI);
            ++done;
        }
        else if(done == 7)
        {   
            tellit(detected);
            llWhisper(0, "AGENT|SCRIPTED");
            llSensor("", "", AGENT | SCRIPTED, 20.0, PI);
            ++done;
        }
        else if(done == 8)
        {   
            tellit(detected);
            llWhisper(0, "ACTIVE|SCRIPTED");
            llSensor("", "", ACTIVE | SCRIPTED, 20.0, PI);
            ++done;
        }
        else if(done == 9)
        {   
            tellit(detected);
            llWhisper(0, "AGENT|ACTIVE|SCRIPTED");
            llSensor("", "", AGENT | ACTIVE | SCRIPTED, 20.0, PI);
            ++done;
        }
        else if(done == 10)
        {   
            tellit(detected);
            llWhisper(0, "PASSIVE|SCRIPTED");
            llSensor("", "", PASSIVE | SCRIPTED, 20.0, PI);
            ++done;
        }
        else if(done == 11)
        {   
            tellit(detected);
            llSay(0, "Phew!");
        }
    }
   
    no_sensor()
    {
        llWhisper(0, "None.");
        if(done == 11)
        {
            llSay(0, "Phew!");
        }
        else
        {
            ++done;
        }
    }
}
</lsl>
See [http://lslwiki.net/lslwiki/wakka.php?wakka=ObjectType Object Type] for details
}}}}
 
}}

Latest revision as of 04:39, 23 October 2010

Constant Description
AGENT Avatars, optionally identified by their display name.
AGENT_BY_LEGACY_NAME Avatars, optionally identified by their legacy name.
AGENT_BY_USERNAME Avatars, optionally identified by their username.
ACTIVE Physical objects that are moving or objects containing an active script.
PASSIVE Non-scripted or script is inactive and non-physical or, if physical, not moving.
SCRIPTED Objects that has any script, which is doing anything in simulator just now.
LAND The simulator's ground segments (only supported by llCastRay()).