Difference between revisions of "Aim Detection"
Jump to navigation
Jump to search
Fred Gandt (talk | contribs) m (Cleaned up style for readability and removed pointless (unused) timer event and llSetPos()) |
|||
Line 1: | Line 1: | ||
This script detects | This script detects who's aiming at you. | ||
<lsl>//This script was designed by | <lsl> | ||
//This script was designed by Han Shuffle | |||
//Cleaned up a bit by another resident. | //Cleaned up a bit by another resident. | ||
//Cleaned up some more by another resident. | |||
default | default | ||
Line 16: | Line 17: | ||
integer i; | integer i; | ||
list sweep; | list sweep; | ||
for(i = 0; i | for (i=0;i<n;++i) | ||
{ | { | ||
if (llGetAgentInfo(llDetectedKey(i)) & AGENT_MOUSELOOK) | |||
if( | |||
{ | { | ||
if( | if (llVecDist(llGetPos(), llDetectedPos(i)+llRot2Fwd(llDetectedRot(i))*llVecDist(llGetPos(),llDetectedPos(i))) < 1.5) | ||
sweep += llDetectedName(i); | sweep += llDetectedName(i); | ||
} | } | ||
if(i == n-1) | if (i == n-1) | ||
llSetText(llDumpList2String( sweep, "\n"), <1.0, 1.0, 1.0>, 1.0); | llSetText(llDumpList2String( sweep, "\n"), <1.0, 1.0, 1.0>, 1.0); | ||
} | } | ||
} | } | ||
}</lsl> | }</lsl> |
Revision as of 13:01, 13 July 2010
This script detects who's aiming at you.
<lsl> //This script was designed by Han Shuffle //Cleaned up a bit by another resident. //Cleaned up some more by another resident.
default {
state_entry() { llSetText("", <1.0, 1.0, 1.0>, 1.0); llSensorRepeat("", "", AGENT, 90, PI, 0.1); } sensor(integer n) { integer i; list sweep; for (i=0;i<n;++i) { if (llGetAgentInfo(llDetectedKey(i)) & AGENT_MOUSELOOK) { if (llVecDist(llGetPos(), llDetectedPos(i)+llRot2Fwd(llDetectedRot(i))*llVecDist(llGetPos(),llDetectedPos(i))) < 1.5) sweep += llDetectedName(i); } if (i == n-1) llSetText(llDumpList2String( sweep, "\n"), <1.0, 1.0, 1.0>, 1.0); } }
}</lsl>