Difference between revisions of "Aim Detection"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with 'This script detects whose aiming at you. <lsl> //This script was designed by TG Scripters, support further scripts by keeping this tag.// //Han Shuffle// default { state_ent...')
 
m (<lsl> tag to <source>)
 
(5 intermediate revisions by 5 users not shown)
Line 1: Line 1:
This script detects whose aiming at you.
This script detects who's aiming at you.
 
<source lang="lsl2">
//This script was designed by Han Shuffle AKA MichaelRyan Allen AKA Dugley Reanimator
//Cleaned up a bit by another resident.
//Cleaned up some more by another resident.


<lsl>
//This script was designed by TG Scripters, support further scripts by keeping this tag.//
//Han Shuffle//
default
default
{
{
     state_entry()
     state_entry()
     {
     {
      // llSetPos(<0,0,0>);
        // black and transparent floattext
      llSensorRepeat("","", AGENT,90,PI,.1);
        llSetText("", ZERO_VECTOR, (float)FALSE);
    }
 
    timer(){
        llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, 90, PI, 0.1);
    llSetText("",<1,1,1>,1); 
        llSetTimerEvent(0);
     }
     }


  sensor(integer n){
    sensor(integer num_detected)
      integer i;
    {
      list sweep;
        list output;
      for(i=0;i!=n;i++){
 
          float dist = llVecDist(llGetPos(),llDetectedPos(i));
        integer i;
        if(llVecDist(llGetPos(),llDetectedPos(i)+llRot2Fwd(llDetectedRot(i))*dist) < 1.5){
        do
            if(llGetAgentInfo(llDetectedKey(i)) & AGENT_MOUSELOOK){
        {
               
            key agentKey = llDetectedKey(i);
          sweep+=llDetectedName(i);
            string agentName = llDetectedName(i);
           
            vector agentPosition = llDetectedPos(i);
            rotation agentRotation = llDetectedRot(i);
            vector ownPosition = llGetPos();
 
            if (llGetAgentInfo(agentKey) & AGENT_MOUSELOOK)
            {
                if (llVecDist(ownPosition, agentPosition+llRot2Fwd(agentRotation)*llVecDist(ownPosition,agentPosition)) < 1.5)
                    output += [agentName];
             }
             }
            }
           
            if(i == n-1){
            llSetText(llDumpList2String( sweep,"\n"),<1,1,1>,1); 
            }
           
         }
         }
     
        while (++i < num_detected);
 
        llSetText(llDumpList2String(output, "\n"), <1.0, 1.0, 1.0>, (float)TRUE);
     }
     }
}
}
 
</source>
</lsl>

Latest revision as of 19:17, 24 January 2015

This script detects who's aiming at you.

//This script was designed by Han Shuffle AKA MichaelRyan Allen AKA Dugley Reanimator
//Cleaned up a bit by another resident.
//Cleaned up some more by another resident.

default
{
    state_entry()
    {
        // black and transparent floattext
        llSetText("", ZERO_VECTOR, (float)FALSE);

        llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, 90, PI, 0.1);
    }

    sensor(integer num_detected)
    {
        list output;

        integer i;
        do
        {
            key agentKey = llDetectedKey(i);
            string agentName = llDetectedName(i);
            vector agentPosition = llDetectedPos(i);
            rotation agentRotation = llDetectedRot(i);
            vector ownPosition = llGetPos();

            if (llGetAgentInfo(agentKey) & AGENT_MOUSELOOK)
            {
                if (llVecDist(ownPosition, agentPosition+llRot2Fwd(agentRotation)*llVecDist(ownPosition,agentPosition)) < 1.5)
                    output += [agentName];
            }
        }
        while (++i < num_detected);

        llSetText(llDumpList2String(output, "\n"), <1.0, 1.0, 1.0>, (float)TRUE);
    }
}