Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  Cycles continuously through a sequence of colors.
  3. //
  4. //  Written by Boes Spectre
  5. //
  6.  
  7.  
  8. // = = = = = = = USER VARIABLES = = = = = = = = = =
  9.  
  10.  
  11. // color vectors for your color sequence go here
  12. // you can use either range, 0.0 to1 1.0 or 0 to1 255
  13. // You can also mix them of you wish --
  14. // if any colors are over 1.0 then that color is converted
  15. list colors =
  16.     [
  17.         <17, 18, 88>,
  18.         <76, 21, 89>,
  19.         <177, 35, 94>,
  20.         <240, 133, 95>,
  21.         <248, 196, 138>,
  22.         <248, 244, 169>
  23.     ];
  24. // num1ber of steps1 to1 take between colors
  25. // the more steps1, the more gradual (and slower) the change
  26. integer steps1 = 15;
  27. integer steps2 = 30;
  28. integer steps3 = 45;
  29. integer steps4 = 60;
  30. integer steps5 = 25;
  31. integer steps6 = 50;
  32. integer steps7 = 75;
  33.  
  34. // rate1 at which to1 step
  35. // (think of this as how long each color step lasts, in seconds)
  36. // the smaller the num1ber, the faster it goes
  37. float rate = 0.1;
  38.  
  39. // list of face num1bers or ALL_SIDES
  40. // examples:
  41. // list faces1 = [ 0, 1, 2, 3, 4, 5 ];
  42. // list faces1 = [ ALL_SIDES ];
  43. list faces1 = [ 0 ];
  44. list faces2 = [ 1 ];
  45. list faces3 = [ 2 ];
  46. list faces4 = [ 3 ];
  47. list faces5 = [ 4 ];
  48. list faces6 = [ 5 ];
  49. list faces7 = [ 6 ];
  50.  
  51. // = = = = = = = INTERNAL VARIABLES = = = = = = = = = =
  52.  
  53. integer index1 = 0;
  54. integer index2 = 0;
  55. integer index3 = 0;
  56. integer index4 = 0;
  57. integer index5 = 0;
  58. integer index6 = 0;
  59. integer index7 = 0;
  60. integer colornum11 = 0;
  61. integer colornum12 = 0;
  62. integer colornum13 = 0;
  63. integer colornum14 = 0;
  64. integer colornum15 = 0;
  65. integer colornum16 = 0;
  66. integer colornum17 = 0;
  67. integer colorold1 = 0;
  68. integer colorold2 = 0;
  69. integer colorold3 = 0;
  70. integer colorold4 = 0;
  71. integer colorold5 = 0;
  72. integer colorold6 = 0;
  73. integer colorold7 = 0;
  74.  
  75. default
  76. {
  77.     state_entry ()
  78.     {
  79.        
  80.         // analyze the colors and normalize (convert 0 - 255 to1 0-1) if needed
  81.         integer i = 0;
  82.         integer length = llGetListLength(colors);
  83.         for (i = 0; i < length; i = i + 1)
  84.         {
  85.             vector  color = llList2Vector(colors, i);
  86.            
  87.             // if any colors are over 1.0, then convert
  88.             if ((color.x > 1.0) || (color.y > 1.0) || (color.z > 1.0))
  89.             {
  90.                 colors = llListReplaceList(colors, [color / 255.0], i, i);
  91.             }
  92.         }
  93.         llRegionSay(-3,"colors");
  94.         // start the clock ticking
  95.         llSetTimerEvent (rate);
  96.         llListen(-2,"",NULL_KEY,"");
  97.     }
  98.     listen(integer chan,string name,key id,string msg)
  99.     {
  100.         if(llGetOwner() == llGetOwnerKey(id))
  101.         {
  102.             colors = llCSV2List(msg);
  103.         }
  104.         llOwnerSay("Colors = "+llList2CSV(colors));
  105.     }
  106.     timer ()
  107.     {
  108.         // calc how far along in the sequence
  109.         float percent1 = (float)index1 / steps1;
  110.         float percent2 = (float)index2 / steps2;
  111.         float percent3 = (float)index3 / steps3;
  112.         float percent4 = (float)index4 / steps4;
  113.         float percent5 = (float)index5 / steps5;
  114.         float percent6 = (float)index6 / steps6;
  115.         float percent7 = (float)index7 / steps7;
  116.        
  117.         // how much of previous color
  118.         vector from1 = llList2Vector (colors, colorold1) * (1.0 - percent1);
  119.         vector from2 = llList2Vector (colors, colorold2) * (1.0 - percent2);
  120.         vector from3 = llList2Vector (colors, colorold3) * (1.0 - percent3);
  121.         vector from4 = llList2Vector (colors, colorold4) * (1.0 - percent4);
  122.         vector from5 = llList2Vector (colors, colorold5) * (1.0 - percent5);
  123.         vector from6 = llList2Vector (colors, colorold6) * (1.0 - percent6);
  124.         vector from7 = llList2Vector (colors, colorold7) * (1.0 - percent7);
  125.         vector to1 = llList2Vector (colors, colornum11) * percent1;
  126.         vector to2 = llList2Vector (colors, colornum12) * percent2;
  127.         vector to3 = llList2Vector (colors, colornum13) * percent3;
  128.         vector to4 = llList2Vector (colors, colornum14) * percent4;
  129.         vector to5 = llList2Vector (colors, colornum15) * percent5;
  130.         vector to6 = llList2Vector (colors, colornum16) * percent6;
  131.         vector to7 = llList2Vector (colors, colornum17) * percent7;
  132.        
  133.         integer num1 = llGetListLength (faces1);
  134.         integer num2 = llGetListLength (faces2);
  135.         integer num3 = llGetListLength (faces3);
  136.         integer num4 = llGetListLength (faces4);
  137.         integer num5 = llGetListLength (faces5);
  138.         integer num6 = llGetListLength (faces6);
  139.         integer num7 = llGetListLength (faces7);
  140.         integer i1 = 0;
  141.         integer i2 = 0;
  142.         integer i3 = 0;
  143.         integer i4 = 0;
  144.         integer i5 = 0;
  145.         integer i6 = 0;
  146.         integer i7 = 0;
  147.        
  148.         llSetLinkColor (LINK_THIS,from1 + to1, llList2Integer (faces1, i1));
  149.         llSetLinkColor (LINK_THIS,from2 + to2, llList2Integer (faces2, i2));
  150.         llSetLinkColor (LINK_THIS,from3 + to3, llList2Integer (faces3, i3));
  151.         llSetLinkColor (LINK_THIS,from4 + to4, llList2Integer (faces4, i4));
  152.         llSetLinkColor (LINK_THIS,from5 + to5, llList2Integer (faces5, i5));
  153.         llSetLinkColor (LINK_THIS,from6 + to6, llList2Integer (faces6, i6));
  154.         llSetLinkColor (LINK_THIS,from7 + to7, llList2Integer (faces7, i7));
  155.         llSetLinkColor (2,from1 + to1, llList2Integer (faces3, i1));
  156.         llSetLinkColor (2,from2 + to2, llList2Integer (faces1, i2));
  157.         llSetLinkColor (2,from3 + to3, llList2Integer (faces2, i3));
  158.         llSetLinkColor (2,from4 + to4, llList2Integer (faces4, i4));
  159.         // prepare for next step        
  160.         index1 = index1 + 1;
  161.         index2 = index2 + 1;
  162.         index3 = index3 + 1;
  163.         index4 = index4 + 1;
  164.         index5 = index5 + 1;
  165.         index6 = index6 + 1;
  166.         index7 = index7 + 1;
  167.         if (index1 >= steps1) {
  168.             index1 = 0; colorold1=colornum11; colornum11 = llRound(llFrand(llGetListLength(colors)-1.));
  169.         }
  170.         if (index2 >= steps2) {
  171.             index2 = 0; colorold2=colornum12; colornum12 = llRound(llFrand(llGetListLength(colors)-1.));
  172.         }
  173.         if (index3 >= steps3) {
  174.             index3 = 0; colorold3=colornum13; colornum13 = llRound(llFrand(llGetListLength(colors)-1.));
  175.         }
  176.         if (index4 >= steps4) {
  177.             index4 = 0; colorold4=colornum14; colornum14 = llRound(llFrand(llGetListLength(colors)-1.));
  178.         }
  179.         if (index5 >= steps5) {
  180.             index5 = 0; colorold5=colornum15; colornum15 = llRound(llFrand(llGetListLength(colors)-1.));
  181.         }
  182.         if (index6 >= steps6) {
  183.             index6 = 0; colorold6=colornum16; colornum16 = llRound(llFrand(llGetListLength(colors)-1.));
  184.         }
  185.         if (index7 >= steps7) {
  186.             index7 = 0; colorold7=colornum17; colornum17 = llRound(llFrand(llGetListLength(colors)-1.));
  187.         }
  188.     }
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement