Difference between revisions of "AGENT BY USERNAME"

From Second Life Wiki
Jump to navigation Jump to search
(Replaced content with "{{LSL Constant |inject-1 |name=AGENT_BY_USERNAME |type=integer |value={{LSL Hex|0x10}} |desc=See {{LSLGC|Avatar/Name|Avatar Names}} |constants={{LSL Constants Sensor|no_wrapp…")
Line 5: Line 5:
|value={{LSL Hex|0x10}}
|value={{LSL Hex|0x10}}
|desc=See {{LSLGC|Avatar/Name|Avatar Names}}
|desc=See {{LSLGC|Avatar/Name|Avatar Names}}
|examples=<lsl>integer type;
|constants={{LSL Constants Sensor|no_wrapper=true|examples=*}}
 
integer done;
 
default
{
    state_entry()
    {
        done = 0;
        llVolumeDetect(TRUE); // I am now very sensitive to touch. So much so I feel things before they touch me.
    }
    collision_start(integer detected)
    {
        type = llDetectedType(0);
        if(type == AGENT)// = 1
        {
            llSay(0, "This is impossible. Since to make contact either I have to be moving or the avatar does.");
        }
        else if(type == ACTIVE)// = 2
        {
            llSay(0, "I have either been struck by a physical moving object or I have struck a stationary physical object.
            In either case the object was not scripted");
        }
        else if(type == PASSIVE)// = 4
        {
            llSay(0, "If I was moving I have struck a non physical object not containing an active script.");
        }
        else if(type == SCRIPTED)// = 8
        {
            llSay(0, "I have struck an object with an active script");
        }
        else if(type == 3)// AGENT & ACTIVE
        {
            llSay(0, "I have definately made contact with an avatar. If I was stationary the avatar was moving.");
        }
        else if(type == 10)// SCRIPTED & ACTIVE
        {
            llSay(0, "I have been struck by a moving phisical object (not an avatar) containing an active script");
        }
        else if(type == 12)// SCRIPTED & PASSIVE
        {
            llSay(0, "I struck a stationary non-physical object (not an avatar) containing an active script");
            //Seems like a good time to try something a bit less confrontational.
            llSensorRepeat("", "", AGENT, 20.0, PI, 1.0); // Radar!! I'll search only for avatars untill I find one.
        }
    }
    sensor(integer detected)
    {
        if(done == 0)
        {    // Now I'll search for moving physical objects (not avatars) scripted or not.
            llSensorRepeat("", "", ACTIVE, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 1)
        {    // Now I'll search for moving physical objects scripted or not and avatars.
            llSensorRepeat("", "", 3, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 2)
        {    // Now I'll search for non physical objects (not avatars) scripted or not.
            llSensorRepeat("", "", PASSIVE, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 3)
        {    // Now I'll search for non physical objects scripted or not and avatars.
            llSensorRepeat("", "", 5, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 4)
        {    // Now I'll search for stationary non physical and physical objects (not avatars) scripted or not.
            llSensorRepeat("", "", 6, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 5)
        {    // Now I'll search for stationary non physical and physical objects scripted or not and avatars.
            llSensorRepeat("", "", 7, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 6)
        {    // Now I'll search for moving physical objects with active scripts.
            llSensorRepeat("", "", SCRIPTED, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 7)
        {    // Now I'll search for moving physical objects with active scripts. Erm... again.
            llSensorRepeat("", "", 9, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 8)
        {    // Now I'll search for stationary, scripted physical objects.
            llSensorRepeat("", "", 10, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 9)
        {    // And again just in case I missed something....*coughs*
            llSensorRepeat("", "", 11, 20.0, PI, 1.0);
            ++done;
        }
        else if(done == 10)
        {    // Even though I did this before I will now finish by searching for any scripted objects.
            llSensorRepeat("", "", 12, 20.0, PI, 1.0);
            ++done;
            llSay(0, "Phew!");
        }
    }
}</lsl>
|constants={{LSL Constants Sensor|no_wrapper=true}}
|functions=
|functions=
{{LSL DefineRow||[[llDetectedType]]|}}
{{LSL DefineRow||[[llDetectedType]]|}}

Revision as of 06:13, 7 January 2011

Description

Constant: integer AGENT_BY_USERNAME = 0x10;

The integer constant AGENT_BY_USERNAME has the value 0x10

See Avatar Names

Caveats


Related Articles

Constants

Flag Mask Description (llDetectedType()) Description (llSensor() and llSensorRepeat() mask)
AGENT_BY_LEGACY_NAME 0x1 Agents This is used to find agents by legacy name.
AGENT 0x1 Agents This is also used to find agents by legacy name, and is functionally identical to AGENT_BY_LEGACY_NAME
AGENT_BY_USERNAME 0x10 Reserved This is used to find agents by username.
ACTIVE 0x2 Physical tasks. (Physical objects & agents) Physical objects that are moving or objects containing an active script. Thus, it is using SL server resources now.
PASSIVE 0x4 Non-physical objects. Non-scripted or script is inactive and non-physical or, if physical, not moving. Thus, it is not using SL server resources now.
SCRIPTED 0x8 Objects containing any active script. Objects that has any script, which is doing anything in simulator just now.
DAMAGEABLE 0x20 Objects & agents that are able to process damage. Filter for objects in world that have a script with on_damage or a final_damage event (able to process damage)
llDetectedType() Scripted Not Scripted Agent Standing Agent Sitting
Physical Movement 10 (ACTIVE|SCRIPTED) 2 (ACTIVE) 3 (ACTIVE|AGENT) 3 (ACTIVE|AGENT)
Non-Physical 12 (PASSIVE|SCRIPTED) 4 (PASSIVE) 1 (AGENT) 5 (PASSIVE|AGENT)

Functions

•  llDetectedType
•  llSensor
•  llSensorRepeat

Examples

Using llDetectedType in collision event:

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 == (AGENT | ACTIVE) ) // 1 + 2
        {
            llSay(0, "I have been struck by an avatar.");
        }
        else if (type == (SCRIPTED | ACTIVE) ) // = 8 + 2
        {
            llSay(0, "I have been struck by a physical object containing any script.");
        }
        else if (type == (SCRIPTED | PASSIVE) ) // = 8 + 4
        {
            llSay(0, "This is impossible. Non-physical objects cannot trigger this event.");
        }
    }
}

Using llDetectedType in sensor event:

default
{
    touch_start(integer numberDetected)
    {
         llSensor("", "", ACTIVE | PASSIVE | AGENT, 20.0, PI); // activates the sensor.
    }

    sensor (integer numberDetected)
    {
        integer i;
        while(i < numberDetected)
        {
            integer type = llDetectedType(i);
            string message;
            message += (string)i + ", " + llDetectedName(i) + ", ";
            list typeList;
            if (type & AGENT)
            {
                typeList += "AGENT";
            }
            if (type & ACTIVE)
            {
                typeList += "ACTIVE";
            }
            if (type & PASSIVE)
            {
                typeList += "PASSIVE";
            }
            if (type & SCRIPTED)
            {
                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."); 
    }
}

Using filter in llSensor* functions:

// Report nearby sensed objects and avatars under sundry categories

list     SenseTypes;
integer  gIndex;

SenseNextType()
{
    string  text = llList2String( SenseTypes, gIndex);
    integer tipe = llList2Integer(SenseTypes, gIndex + 1);
    if (tipe)
    {
        llWhisper(0, text);
        llSensor("", NULL_KEY, tipe, 20.0, PI);
        gIndex += 2;   // increment by stride
    }
    else
        llWhisper(0, "--- Finished ---");
}

default
{
    touch_start(integer detected)
    {
        // Make a Strided list of text and sensor type combinations
        // (Can't use '|' in Global, unfortunately)
        SenseTypes = [
            "AGENT_BY_LEGACY_NAME", AGENT_BY_LEGACY_NAME,
            "ACTIVE", ACTIVE,
            "AGENT_BY_LEGACY_NAME|ACTIVE", AGENT_BY_LEGACY_NAME|ACTIVE,
            "PASSIVE", PASSIVE,
            "AGENT_BY_LEGACY_NAME|PASSIVE", AGENT_BY_LEGACY_NAME|PASSIVE,
            "ACTIVE|PASSIVE", ACTIVE|PASSIVE,
            "AGENT_BY_LEGACY_NAME|ACTIVE|PASSIVE", AGENT_BY_LEGACY_NAME|ACTIVE|PASSIVE,
            "SCRIPTED", SCRIPTED,
            "AGENT|SCRIPTED", AGENT|SCRIPTED,
            "ACTIVE|SCRIPTED", ACTIVE|SCRIPTED,
            "AGENT_BY_LEGACY_NAME|ACTIVE|SCRIPTED", AGENT_BY_LEGACY_NAME|ACTIVE|SCRIPTED,
            "PASSIVE|SCRIPTED", PASSIVE|SCRIPTED,
            "", 0 ];
        gIndex = 0;
        SenseNextType();        // Kick off the sensing sequence
    }
    sensor(integer detected)
    {
        integer x;
        while (x < detected)
        {
            llWhisper(0, (string) (x+1) + ": " + llDetectedName(x) );
            ++x;
        }
        SenseNextType();
    }
    no_sensor()
    {
        llWhisper(0, "none");
        SenseNextType();
    }
}

Detecting damageable things with sensors:

default
{
    state_entry()
    {
        llSensor("", "", SCRIPTED|AGENT|DAMAGEABLE, 20, PI);
    }

    no_sensor()
    {
        llOwnerSay("Nothing detected");
    }

    sensor(integer num_detected)
    {
        llOwnerSay("Detected " + (string)num_detected + " damageable thing(s)");
        integer i;
        for (i = 0; i < num_detected; ++i)
        {
            string name = llDetectedName(i);
            integer isAgent = llDetectedType(i) & AGENT;
            list types = ["Object", "Agent"];

            llOwnerSay(llList2String(types, isAgent) + ": " + name);
        }
    }
}

Deep Notes

Search JIRA for related Issues

Signature

integer AGENT_BY_USERNAME = 0x10;