Avatar Radar (NewAge): Difference between revisions
No edit summary |
No edit summary |
||
| Line 185: | Line 185: | ||
} | } | ||
people += "Region Agent Count = "+(string)llGetRegionAgentCount()+"\nAgents in Range = "+(string)llGetListLength(chat_range)+"\n"; | people += "Region Agent Count = "+(string)llGetRegionAgentCount()+"\nAgents in Range = "+(string)llGetListLength(chat_range)+"\n"; | ||
people = "No People In Range"; | people = "No People In Range\n"; | ||
llLagStatus(); | llLagStatus(); | ||
all_status(); | all_status(); | ||
Revision as of 02:55, 21 July 2010
Just copy and paste this script into an object that will be your hud!
<lsl> ///////////////////////////////// // New Age Radar Script // By Asia Snowfall // Version 1.1 ///////////////////////////////// // v1.1; // ------ // (Added) - Agent Count in Region when no agents in sensor range // (Added) - Lag Status when no agents in sensor range ///////////////////////////////// // v1.0 // ------ // (Initial Release) /////////////////////////////////
float scan_range = 100; float speed = 2; integer channel = 1; integer show_total_agents_in_chat_range = TRUE; integer show_total_agents_in_region = TRUE; integer show_lag_status = TRUE;
integer handler;
string people; list people_in_sensor_range; list people_in_sensor_vectors; list chat_range;
integer max_people = 7;
string lag_status; vector text_color;
llLagStatus()
{
float time_dilation = llGetRegionTimeDilation();
if(time_dilation <= 0.3)
{
lag_status = "Laggy";
text_color = <1.0,0.0,0.0>;
}
else if(time_dilation > 0.3 && time_dilation <= 0.5)
{
lag_status = "Not Bad";
text_color = <1.0,1.0,0.0>;
}
else if(time_dilation > 0.5 && time_dilation <= 0.8)
{
lag_status = "Good";
text_color = <0.0,1.0,0.0>;
}
else if(time_dilation > 0.8 && time_dilation <= 1.0)
{
lag_status = "Excellent";
text_color = <0.0,1.0,1.0>;
}
}
all_status() {
if(show_total_agents_in_region == TRUE)
{
people += "Region Agent Count = "+(string)llGetRegionAgentCount()+"\n";
}
if(show_total_agents_in_chat_range == TRUE)
{
people += "Agents in Range = "+(string)llGetListLength(chat_range)+"\n";
}
if(show_lag_status == TRUE)
{
people += "Lag Status = "+lag_status;
}
}
default {
state_entry()
{
llSensor("", "", AGENT, scan_range, PI);
llSetTimerEvent(speed);
}
attach(key id)
{
if(id == llGetOwner())
{
handler = llListen(channel, "", "", "");
llOwnerSay("Find location of avatar within sensor range by typing either their full or partial name on channel "+(string)channel + ", example; /"+(string)channel+" Mark");
}
else if(id == NULL_KEY)
{
llListenRemove(handler);
}
}
listen(integer channel, string name, key id, string str)
{
if(id == llGetOwner())
{
str = llToLower(str);
integer index = llListFindList(people_in_sensor_range, [str]);
if(index != -1)
{
llOwnerSay(llList2String(people_in_sensor_range, index)+" is located at "+llList2String(people_in_sensor_vectors, index));
}
else if(index == -1)
{
integer i = 0;
integer length = llGetListLength(people_in_sensor_range);
integer ind;
do
{
if(llStringLength(llList2String(people_in_sensor_range, i)) > 0)
{
ind = llSubStringIndex(llList2String(people_in_sensor_range, i), str);
if(ind != -1)
{
llOwnerSay(llList2String(people_in_sensor_range, i) + " is located at "+llList2String(people_in_sensor_vectors, i));
return;
}
}
}while(i++<length);
llOwnerSay("No Avatars Found by the name or partial name of "+str);
}
}
}
changed(integer h)
{
if(h & CHANGED_OWNER)
{
llResetScript();
}
}
sensor(integer x)
{
people_in_sensor_range = [];
people_in_sensor_vectors = [];
integer i = 0;
integer index;
--x;
if(x > max_people)
{
x = max_people-1;
}
do
{
index = llListFindList(chat_range, [llDetectedName(i)]);
if(llStringLength(llDetectedName(i)) >! 0)
{
if(llVecDist(llDetectedPos(i), llGetPos()) <= 20)
{
if(index == -1)
{
chat_range += llDetectedName(i);
llOwnerSay(llDetectedName(i) + " has entered chat range");
}
}
else
{
if(index != -1)
{
llOwnerSay(llDetectedName(i) + " has left chat range");
chat_range = llDeleteSubList(chat_range, index, index);
}
}
people_in_sensor_range += llToLower(llDetectedName(i));
people_in_sensor_vectors += llDetectedPos(i);
people += llDetectedName(i) + " - " + llGetSubString((string)llVecDist(llDetectedPos(i), llGetPos()), 0, 4)+"m\n";
}
}while(i++<x);
llLagStatus();
all_status();
llSetText(people, text_color, 1.0);
people = "";
}
no_sensor()
{
if(llGetListLength(chat_range) > 0)
{
chat_range = [];
}
people += "Region Agent Count = "+(string)llGetRegionAgentCount()+"\nAgents in Range = "+(string)llGetListLength(chat_range)+"\n";
people = "No People In Range\n";
llLagStatus();
all_status();
llSetText(people, text_color, 1.0);
people = "";
}
timer()
{
llSensor("", "", AGENT, scan_range, PI);
}
} </lsl>