Advertisement
cyber_Ahn

Simwide Radar colored distance

May 6th, 2016
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //simpel simwide radar
  2. //you need one - three prims named like the primNames list
  3.  
  4.  
  5. integer output = 3; // 1 = one prim text green / 2 = two prims first green in 20m, second yellow over 20m / 3 = three prims first green in 20m, second yellow 20m - 96m, third over 96m
  6. list primNames = ["r1","r2","r3"];// name of the prims
  7. list av;
  8. string text_1;
  9. string text_2;
  10. string text_3;
  11. vector color_1 = <0,1,0>;
  12. vector color_2 = <1,1,0>;
  13. vector color_3 = <1,0,0>;
  14. render_display()
  15. {
  16.     integer num = llGetListLength(av);
  17.     integer x;
  18.     list cach = [];
  19.     for(x=0;x<=(num-1);x++)
  20.     {
  21.         if(llList2Key(av,x)!=llGetOwner())
  22.         {
  23.             list pos = llGetObjectDetails(llList2Key(av,x),[OBJECT_POS]);
  24.             integer range = (integer)llVecDist((vector)llList2String(llGetObjectDetails(llList2Key(av,x),[OBJECT_POS]),0),llGetPos());
  25.             cach += range;
  26.             cach += llKey2Name(llList2Key(av,x));
  27.         }
  28.     }
  29.     cach = llListSort(cach,2,TRUE);
  30.     if(output == 1)
  31.     {
  32.         text_1 = "";
  33.         integer nu = llGetListLength(cach);
  34.         integer y;
  35.         for(y=0;y<=(nu-1);y=y+2)
  36.         {
  37.             text_1 = text_1 + llList2String(cach,(y+1))+" "+(string)llList2Integer(cach,y)+"m \n";
  38.         }
  39.     }
  40.     if(output == 2)
  41.     {
  42.         text_1 = "";
  43.         text_2 = "";
  44.         integer nu = llGetListLength(cach);
  45.         integer y;
  46.         for(y=0;y<=(nu-1);y=y+2)
  47.         {
  48.             if(llList2Integer(cach,y) < 21)
  49.             {
  50.                 text_1 = text_1 + llList2String(cach,(y+1))+" "+(string)llList2Integer(cach,y)+"m \n";
  51.             }
  52.             else
  53.             {
  54.                 text_2 = text_2 + llList2String(cach,(y+1))+" "+(string)llList2Integer(cach,y)+"m \n";
  55.             }
  56.         }
  57.     }
  58.     if(output == 3)
  59.     {
  60.         text_1 = "";
  61.         text_2 = "";
  62.         text_3 = "";
  63.         integer nu = llGetListLength(cach);
  64.         integer y;
  65.         for(y=0;y<=(nu-1);y=y+2)
  66.         {
  67.             if(llList2Integer(cach,y) < 21)
  68.             {
  69.                 text_1 = text_1 + llList2String(cach,(y+1))+" "+(string)llList2Integer(cach,y)+"m \n";
  70.             }
  71.             else if(llList2Integer(cach,y) < 97)
  72.             {
  73.                 text_2 = text_2 + llList2String(cach,(y+1))+" "+(string)llList2Integer(cach,y)+"m \n";
  74.             }
  75.             else
  76.             {
  77.                 text_3 = text_3 + llList2String(cach,(y+1))+" "+(string)llList2Integer(cach,y)+"m \n";
  78.             }
  79.         }
  80.     }
  81.     integer num_p = llGetNumberOfPrims();
  82.     integer z;
  83.     for(z=0;z<=num_p;z++)
  84.     {
  85.         if(llGetLinkName(z)==llList2String(primNames,0))
  86.         {
  87.             llSetLinkPrimitiveParamsFast(z,[PRIM_TEXT,text_1,color_1,1.0]);
  88.         }
  89.         if(llGetLinkName(z)==llList2String(primNames,1))
  90.         {
  91.             llSetLinkPrimitiveParamsFast(z,[PRIM_TEXT,text_2,color_2,1.0]);
  92.         }
  93.         if(llGetLinkName(z)==llList2String(primNames,2))
  94.         {
  95.             llSetLinkPrimitiveParamsFast(z,[PRIM_TEXT,text_3,color_3,1.0]);
  96.         }
  97.     }
  98.     llSetTimerEvent(1);
  99. }
  100. default
  101. {
  102.     state_entry()
  103.     {
  104.         av = llGetAgentList(AGENT_LIST_REGION,[]);
  105.         llSetTimerEvent(1);
  106.     }
  107.     on_rez(integer param)
  108.     {
  109.         llResetScript();
  110.     }
  111.     attach(key attached)
  112.     {
  113.         if (attached != NULL_KEY)
  114.         {
  115.             llResetScript();
  116.         }
  117.     }
  118.     timer()
  119.     {
  120.         llSetTimerEvent(0);
  121.         if(llGetListLength(av) != llGetListLength(llGetAgentList(AGENT_LIST_REGION,[])))
  122.         {
  123.             av = llGetAgentList(AGENT_LIST_REGION,[]);
  124.         }
  125.         render_display();
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement