Difference between revisions of "Aim Detection"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) m (some readability improvements) |
|||
Line 10: | Line 10: | ||
state_entry() | state_entry() | ||
{ | { | ||
llSetText("", | // black and transparent floattext | ||
llSensorRepeat("", "", | llSetText("", ZERO_VECTOR, (float)FALSE); | ||
llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, 90, PI, 0.1); | |||
} | } | ||
sensor(integer | |||
sensor(integer num_detected) | |||
{ | { | ||
list output; | |||
integer i; | 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( | if (llVecDist(ownPosition, agentPosition+llRot2Fwd(agentRotation)*llVecDist(ownPosition,agentPosition)) < 1.5) | ||
output += [agentName]; | |||
} | } | ||
} | } | ||
while (++i < n); | |||
llSetText(llDumpList2String(output, "\n"), <1.0, 1.0, 1.0>, (float)TRUE); | |||
} | } | ||
}</lsl> | } | ||
</lsl> |
Revision as of 10:30, 16 October 2012
This script detects who's aiming at you.
<lsl> //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 < n);
llSetText(llDumpList2String(output, "\n"), <1.0, 1.0, 1.0>, (float)TRUE); }
} </lsl>