-->

FoxSan's 3D Tools and LSL Script Repository

Tons of LSL scripts, examples and 3D tools, free for all. There are currently 207 scripts and articles in this database.

Look At Example

string person;
integer found;
 
default
{
    state_entry()
    {
        llSetColor(<1,1,1>, ALL_SIDES);
        llListen(0, "", llGetOwner(), "");
    }
    listen(integer channel, string name, key id, string message)
    {
        string lowerMessage = llToLower(message);
 
        if (lowerMessage == "reset look")
        {
            //Remove the sensor
            llSay(0, "Removing Look");
            llSensorRemove();
        }
        if(llSubStringIndex(lowerMessage, "look at") >= 0)
        {
            //Remove the Previous Sensor
            llSensorRemove();
 
            //Get the name of the person
            person = llGetSubString(message, 8, llStringLength(message));
 
            //Setup a repeating sensor
            found = FALSE;
            llSetColor(<0,0,1>, ALL_SIDES);
            llSay(0, "Scanning for " + person);
            llSensorRepeat(person, NULL_KEY, AGENT, 96, TWO_PI, 0.5);
        }
    }
    no_sensor()
    {
        //Remove Sensor if Avatar not found
        llSay(0, person + " not found. Removing Look.");
        llSetColor(<1,0,0>, ALL_SIDES);
        llSensorRemove();
        llSleep(2);
        llSetColor(<1,1,1>, ALL_SIDES);
    }
    sensor(integer num_detected)
    {
        if (!found)
        {
            llSetColor(<0,1,0>, ALL_SIDES);
            llSay(0, (string)num_detected);
            llSay(0, "Found " + person + ".");
        }
        found = TRUE;
        //Get postion of detected Agent
        vector pos = llDetectedPos(0);
 
        //Point our prim to look at them
        llLookAt(pos, 1.0, 1.0);
    }
}

Comments are closed.