SHARE
TWEET

Avatar2Hud

a guest Jul 11th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //"043e4cec-eb70-4700-a8ca-f514c11ed625" = FailedScience Resident
  2.  
  3. list keys_to_ignore = ["043e4cec-eb70-4700-a8ca-f514c11ed625"];
  4.  
  5. vector project3D(vector pos) {
  6.     //Help from Mikkel Mercy
  7.     vector between = (pos - llGetCameraPos()) * (<0.0f, 0.0f, 0.0f, 1.0f> / llGetCameraRot());
  8.     between = <-between.y, between.z, between.x>;
  9.     float c = llTan(1.047198f / 2.0f);
  10.     vector local_pos = <(between.x * (1.0f / c)) / between.z,
  11.                         (between.y * (1.0f / c)) / between.z,
  12.                         (between.z - 2.0) / between.z>;
  13.                        
  14.     vector ret = (<0.0f, -local_pos.x, local_pos.y> / 2.0f)+<0,0.7901,0.2886>;
  15.    
  16.     if(local_pos.z < -1.0f || local_pos.z > 1.0f){
  17.         return <0.0f, 0.0f, -2.0f>;  
  18.     }
  19.     return ret;
  20. }
  21. test(){
  22.     integer x = 0;
  23.     vector local;
  24.     vector target;
  25.     list keys = llGetAgentList(AGENT_LIST_REGION, []);
  26.     integer point = llListFindList(keys,[llGetOwner()]);
  27.     keys = llDeleteSubList(keys,point,point);
  28.     integer s = llGetListLength(keys);
  29.     for(;x<s;++x) {
  30.         key ck = llList2Key(keys,x);
  31.         if(llListFindList(keys_to_ignore,[(string)ck]) != -1){
  32.             jump end;
  33.         }else{
  34.             vector dp = (vector)((string)llGetObjectDetails(ck,[OBJECT_POS]));
  35.             string dn = llKey2Name(ck);
  36.             if(dn == "")jump end;
  37.             if(ck == "" || ck == NULL_KEY)jump end;
  38.             vector pos = project3D(dp);
  39.             string out_text = dn +  " (" + (string)llFloor(llVecDist(llGetPos(),dp))+"m)"+ llList2String(llGetObjectDetails(llList2Key(keys,x),[OBJECT_TOTAL_SCRIPT_COUNT]),0);
  40.            
  41.             if(!llSameGroup(ck)){
  42.                 llSetLinkPrimitiveParamsFast(17 + x,[PRIM_TEXT, out_text, <0.75f, 0.0f, 0.0f>, 0.75f,PRIM_POSITION, pos,PRIM_COLOR,-1,<0.75f, 0.0f, 0.0f>,1.0,PRIM_NAME,"target,"+dn,PRIM_DESC,(string)ck]);
  43.             }
  44.             else{
  45.                 llSetLinkPrimitiveParamsFast(17 + x,[PRIM_TEXT, out_text, <0.0f, 0.75f, 0.0f>, 0.75f,PRIM_POSITION, pos,PRIM_COLOR,-1,<0.0f,0.75f,0.0f>,1.0,PRIM_NAME,"target,"+dn,PRIM_DESC,(string)ck]);
  46.             }
  47.         }
  48.         @end;
  49.     }
  50.     for(;x<llGetNumberOfPrims()+1;++x){
  51.         llSetLinkPrimitiveParamsFast(17 + x,[PRIM_POSITION,<-2,-2,-2>,PRIM_NAME,"Object",PRIM_DESC,"NULL"]);
  52.     }  
  53. }
  54. clear_prims(){
  55.     integer x = 17;
  56.     for(;x<llGetNumberOfPrims()+1;++x){
  57.         llSetLinkPrimitiveParamsFast(x, [PRIM_TEXT,"", <0.75f, 0.0f, 0.0f>, 0.75f,PRIM_SIZE, <0.03f, 0.03f, 0.03f>,PRIM_POSITION,<-2,-2,-2>,PRIM_COLOR,-1,<0.75f, 0.0f, 0.0f>,1.0,PRIM_NAME,"Object",PRIM_DESC,"NULL"]);
  58.     }  
  59.     llSetText("",<1,1,1>,1);
  60. }
  61. list in_sim(){
  62.     list out;
  63.     list keys = llGetAgentList(AGENT_LIST_REGION, []);
  64.     integer numberOfKeys = llGetListLength(keys);
  65.     vector currentPos = llGetPos();
  66.     list newkeys;
  67.     key thisAvKey;
  68.     integer i;
  69.     for (i = 0; i < numberOfKeys; ++i) {
  70.         thisAvKey = llList2Key(keys,i);
  71.         newkeys += [llRound(llVecDist(currentPos,llList2Vector(llGetObjectDetails(thisAvKey, [OBJECT_POS]), 0))),thisAvKey];
  72.     }
  73.     newkeys = llListSort(newkeys, 2, TRUE);
  74.     for (i = 0; i < (numberOfKeys * 2); i += 2) {
  75.         if(llList2Key(newkeys, i+1)!=llGetOwner() && llList2Key(newkeys, i+1)!= NULL_KEY){
  76.             out+=llGetSubString(llKey2Name(llList2Key(newkeys, i+1)),0,5)+" ("+ (string) llList2Integer(newkeys, i) + "m)" + llList2String(llGetObjectDetails(llList2Key(newkeys,i+1),[OBJECT_TOTAL_SCRIPT_COUNT]),0);
  77.         }
  78.     }
  79.     return out;
  80. }
  81. say(string m){
  82.     llMessageLinked(-1,-560,m,llGetOwner());
  83. }
  84.  
  85. integer display = 1;
  86. integer on = 1;
  87. default{
  88.     on_rez(integer r) {
  89.         llResetScript();
  90.     }
  91.     changed(integer c){
  92.         if(c & CHANGED_REGION){
  93.             clear_prims();
  94.             test();
  95.         }if(c & CHANGED_TELEPORT){
  96.             clear_prims();
  97.             test();
  98.         }
  99.     }
  100.     state_entry(){
  101.         if(llGetAttached()){
  102.             clear_prims();
  103.             llSetPos(<0,-0.7901,-0.2886>);
  104.             llRequestPermissions(llGetOwner(), PERMISSION_TRACK_CAMERA);
  105.         }
  106.     }
  107.     run_time_permissions(integer p){
  108.         if(p & PERMISSION_TRACK_CAMERA){
  109.             llSetTimerEvent(0.0000001f);
  110.         }
  111.         else{
  112.             llResetScript();
  113.         }
  114.     }link_message(integer s,integer n,string msg,key i){
  115.         if(n == -420){
  116.             string m = llToLower(msg);
  117.             if(m == "target off"){
  118.                 on = 0;
  119.                 clear_prims();
  120.                 say("Targeting system turned off.");
  121.             }
  122.             if(m == "target on"){
  123.                 on = 1;
  124.                 if(llGetPermissions() & PERMISSION_TRACK_CAMERA){
  125.                     test();
  126.                     llSetTimerEvent(0.0000001f);
  127.                 }else{
  128.                     llResetScript();
  129.                 }
  130.                 say("Targeting system turned on.");
  131.             }
  132.             if(m == "text on"){
  133.                 display = 1;
  134.                 say("Display text is now turned on.");
  135.             }
  136.             if(m == "text off"){
  137.                 display = 0;
  138.                 say("Display text is now turned off");
  139.                 llSetText("",<1,1,1>,1);
  140.             }
  141.         }
  142.     }
  143.     timer(){
  144.         if(display){
  145.             llSetText(llDumpList2String(in_sim(),"\n"),<1,1,1>,1);
  146.         }
  147.         if(!display){
  148.             llSetText("",<1,1,1>,1);
  149.         }
  150.         if(on){
  151.             test();
  152.         }
  153.         if(!on){
  154.             llSetTimerEvent(0.0);
  155.         }
  156.     }
  157. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top