Advertisement
cyber_Ahn

functions_lib.lsl

Oct 20th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //small functions lib
  2. //update coming soon
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10. //------get primsize------
  11. getscale()
  12. {
  13.     list data = llGetPrimitiveParams([PRIM_SIZE]);
  14.     vector scale = llList2Vector(data,0);
  15.     return scale;
  16. }
  17. vector key2location(key UUID)
  18. {
  19.     list Data = llGetObjectDetails(UUID, ([OBJECT_POS]) );
  20.     return (vector)llList2String(Data, 0);
  21. }
  22. //-------set link alpha-------
  23. set_alpha(string prim, float alpha, integer face)
  24. {
  25.     integer num = llGetNumberOfPrims();
  26.     integer x;
  27.     for(x=0;x<=num;x++)
  28.     {
  29.         if(llGetLinkName(x)==prim)
  30.         {
  31.             llSetLinkAlpha(x,alpha,face);
  32.         }
  33.     }
  34. }
  35. //----------crypt-------
  36. string pass = "1234";
  37. string token()
  38. {
  39.     string token = (string)(271101+21981+10879)+llGetDate()+(string)llGetTime()+(string)(31184+241259+61259);
  40.     return token;
  41. }
  42. string crypt(string data)
  43. {
  44.     string crypt = llXorBase64StringsCorrect(llStringToBase64(data),llStringToBase64(pass+token()));
  45.     return crypt;
  46. }
  47. string decrypt(string data)
  48. {
  49.     string decrypt = llBase64ToString(llXorBase64StringsCorrect(data,llStringToBase64(pass+token())));
  50.     return decrypt;
  51. }
  52. //------set link color------
  53. set_color(string prim,vector color,integer face)
  54. {
  55.     integer num = llGetNumberOfPrims();
  56.     integer i;
  57.     for(i=0;i<=num;i++)
  58.     {
  59.         if(llGetLinkName(i)==prim)
  60.         {
  61.             llSetLinkColor(i,color,face);
  62.         }
  63.     }
  64. }
  65. //-------set link texture-------
  66. set_texture(string prim,key text,integer face,vector repeats,vector offsets,float rot)
  67. {
  68.     integer num = llGetNumberOfPrims();
  69.     integer i;
  70.     for(i=0;i<=num;i++)
  71.     {
  72.         if(llGetLinkName(i)==prim)
  73.         {
  74.             llSetLinkPrimitiveParamsFast(i,[PRIM_TEXTURE,face,text,repeats,offsets, (rot*DEG_TO_RAD)]);
  75.         }
  76.     }
  77. }
  78. //------generate a menu ------
  79. integer handle;
  80. integer menuChan;
  81. makeMenu(key id, string menutext, list buttons)
  82. {
  83.     llListenRemove(handle);
  84.     menuChan = 50000 + (integer)llFrand(50000.00);
  85.     handle = llListen(menuChan,"",NULL_KEY,"");
  86.     llDialog(id,menutext,buttons,menuChan);
  87. }
  88. //--- data in list?-----
  89. list visitor_list;
  90. integer isNameOnList( string name )
  91. {
  92.     integer len = llGetListLength( visitor_list );
  93.     integer i;
  94.     for( i = 0; i < len; i++ )
  95.     {
  96.         if( llList2String(visitor_list, i) == name )
  97.         {
  98.             return TRUE;
  99.         }
  100.     }
  101.     return FALSE;
  102. }
  103. //------rgb to alpha-------
  104. vector RgbToAlpha(vector Rgb)
  105. {
  106.     return <(integer)(Rgb.x * 255.0),(integer)(Rgb.y * 255.0),(integer)(Rgb.z * 255.0)>;
  107. }
  108. //----- alpha  to rgb-----
  109. vector AlphaToRgb(vector Alpha)
  110. {
  111.     return <(Alpha.x / 255.0),(Alpha.y / 255.0),(Alpha.z / 255.0)>;
  112. }
  113.  
  114.  
  115.  
  116. default
  117. {
  118.     state_entry()
  119.     {
  120.         //example rgb to alpha
  121.         llSay(0,(string)RgbToAlpha(<1,0.3456,0.4678>));
  122.     }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement