Advertisement
Guest User

Avatar Color Control Scripts

a guest
Apr 25th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string MODE;
  2. float INTERVAL = 1.0;
  3. vector COLOR = <255.0, 0.0, 0.0>;
  4. string PROGRESSION = "cycling";
  5. integer STRIPEY = FALSE;
  6. key INVISI = "38b86f85-2575-52a9-a531-23108d8da837";
  7. key STRIPES = "267cb98c-3d08-0baa-e3da-c46522361548";
  8.  
  9. set_colors(vector sent_color)
  10. {
  11.     llSay(265, (string)sent_color);
  12.     llMessageLinked(0, 3, (string)sent_color, NULL_KEY);
  13.     llSleep(0.05);
  14.     llSetColor(sent_color, 0);
  15. }
  16.  
  17. set_stripes()
  18. {
  19.     if (!STRIPEY)
  20.     {
  21.         STRIPEY = TRUE;
  22.         llSetTexture(STRIPES, 0);
  23.         llSay(265, "stripeon");
  24.     }
  25.     else
  26.     {`
  27.         STRIPEY = FALSE;
  28.         llSetTexture(TEXTURE_BLANK, 0);
  29.         llSay(265, "stripeoff");
  30.     }
  31. }
  32.  
  33. float midpoint(float first, float second)
  34. {
  35.     float output;
  36.     if (first > second)
  37.     {
  38.         output = (second + ((first - second) / 2.0));
  39.     }
  40.     else if (first < second)
  41.     {
  42.         output = (first + ((second - second) / 2.0));
  43.     }
  44.     else
  45.     {
  46.         output = first;
  47.     }
  48.     return output;
  49. }
  50.  
  51. //###########################################################################################
  52.  
  53. default //linear
  54. {
  55.     state_entry()
  56.     {
  57.         COLOR = <255.0, 0.0, 0.0>;
  58.         MODE = "linear";
  59.         PROGRESSION = "cycling";
  60.         llListen(623568, "", llGetOwner(), "");
  61.         if (INTERVAL < 0.5) INTERVAL = 0.5;
  62.         llSetTimerEvent(INTERVAL);
  63.         llSetTextureAnim(ANIM_ON | LOOP | SMOOTH, 0, 7, 1, 6, 0, 1);
  64.         llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  65.     }
  66.     touch_start(integer total_number)
  67.     {
  68.         if (llDetectedKey(0) == llGetOwner())
  69.         {
  70.             if (PROGRESSION == "cycling")
  71.             {
  72.                 llSetTimerEvent(0.0);
  73.                 PROGRESSION = "static";
  74.                 llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  75.             }
  76.             else
  77.             {
  78.                 llSetTimerEvent(INTERVAL);
  79.                 PROGRESSION = "cycling";
  80.                 llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  81.             }
  82.         }
  83.     }
  84.     listen(integer channel, string name, key id, string message)
  85.     {
  86.         list parsed = llParseString2List(message, [" "], []);
  87.         string command = llList2String(parsed, 0);
  88.         if ((llList2Float(parsed, 1) > 0.0) && ((command == "linear") || (command == "random") || (command == "step")))
  89.         {
  90.             INTERVAL = llList2Float(parsed, 1);
  91.             if ((INTERVAL == 0.0) || (INTERVAL < 0.5))
  92.             {
  93.                 INTERVAL = 0.5;
  94.             }
  95.             llSetTimerEvent(INTERVAL);
  96.         }
  97.         if (command == "step")  
  98.         {
  99.             llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  100.         }
  101.         if (command == "solid")
  102.         {
  103.             if (llGetListLength(parsed) == 4)
  104.             {
  105.                 COLOR.x = llList2Float(parsed, 1);
  106.                 COLOR.y = llList2Float(parsed, 2);
  107.                 COLOR.z = llList2Float(parsed, 3);
  108.                 state solid;
  109.             }
  110.             else
  111.             {
  112.                 llSay(2389547, "Please provide 3 values for RGB");
  113.             }
  114.         }
  115.         if (command == "invisi")
  116.         {
  117.             state invisi;
  118.         }
  119.         if (command == "random")
  120.         {
  121.             state random;
  122.         }
  123.         if (command == "chaos")
  124.         {
  125.             state chaos;
  126.         }
  127.         if (command == "stripes")
  128.         {
  129.             set_stripes();
  130.         }
  131.     }
  132.     timer()
  133.     {
  134.         if ((COLOR.x == 255.0) && (COLOR.y >= 0.0) && (COLOR.y < 255.0) && (COLOR.z == 0.0))
  135.         {
  136.             ++COLOR.y;
  137.             set_colors(llVecNorm(COLOR));
  138.         }
  139.         else if ((COLOR.x <= 255.0) && (COLOR.x > 0.0) && (COLOR.y == 255.0) && (COLOR.z == 0.0))
  140.         {
  141.             --COLOR.x;
  142.             set_colors(llVecNorm(COLOR));
  143.         }
  144.         else if ((COLOR.x == 0.0) && (COLOR.y == 255.0) && (COLOR.z >= 0.0) && (COLOR.z < 255.0))
  145.         {
  146.             ++COLOR.z;
  147.             set_colors(llVecNorm(COLOR));
  148.         }
  149.         else if ((COLOR.x == 0.0) && (COLOR.y <= 255.0) && (COLOR.y > 0.0) && (COLOR.z == 255.0))
  150.         {
  151.             --COLOR.y;
  152.             set_colors(llVecNorm(COLOR));
  153.         }
  154.         else if ((COLOR.x >= 0.0) && (COLOR.x < 255.0) && (COLOR.y == 0.0) && (COLOR.z == 255.0))
  155.         {
  156.             ++COLOR.x;
  157.             set_colors(llVecNorm(COLOR));
  158.         }
  159.         else if ((COLOR.x == 255.0) && (COLOR.y == 0.0) && (COLOR.z <= 255.0) && (COLOR.z > 0.0))
  160.         {
  161.             --COLOR.z;
  162.             set_colors(llVecNorm(COLOR));
  163.         }
  164.     }
  165. }
  166.  
  167. //###########################################################################################
  168.  
  169. state solid
  170. {
  171.     state_entry()
  172.     {
  173.         llSetTimerEvent(0.0);
  174.         MODE = "solid";
  175.         PROGRESSION = "static";
  176.         llListen(623568, "", llGetOwner(), "");
  177.         llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  178.         if ((COLOR.x > 1.0) || (COLOR.y > 1.0) || (COLOR.z > 1.0))
  179.         {
  180.             set_colors(llVecNorm(COLOR));
  181.         }
  182.         else
  183.         {
  184.             set_colors(COLOR);
  185.         }
  186.     }
  187.     listen(integer channel, string name, key id, string message)
  188.     {
  189.         list parsed = llParseString2List(message, [" "], []);
  190.         string command = llList2String(parsed, 0);
  191.         if (command == "solid")
  192.         {
  193.             if (llGetListLength(parsed) == 4)
  194.             {
  195.                 COLOR.x = llList2Float(parsed, 1);
  196.                 COLOR.y = llList2Float(parsed, 2);
  197.                 COLOR.z = llList2Float(parsed, 3);
  198.                 if ((COLOR.x > 1.0) || (COLOR.y > 1.0) || (COLOR.z > 1.0))
  199.                 {
  200.                     set_colors(llVecNorm(COLOR));
  201.                 }
  202.                 else
  203.                 {
  204.                     set_colors(COLOR);
  205.                 }
  206.             }
  207.             else
  208.             {
  209.                 llSay(2389547, "Please provide 3 values for RGB");
  210.             }
  211.         }
  212.         if ((llList2Float(parsed, 1) > 0.0) && ((command == "linear") || (command == "random") || (command == "step")))
  213.         {
  214.             INTERVAL = llList2Float(parsed, 1);
  215.         }
  216.         if (command == "step")  
  217.         {
  218.             llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  219.         }
  220.         if (command == "linear")
  221.         {
  222.             state default; //linear
  223.         }
  224.         if (command == "invisi")
  225.         {
  226.             state invisi;
  227.         }
  228.         if (command == "random")
  229.         {
  230.             state random;
  231.         }
  232.         if (command == "chaos")
  233.         {
  234.             state chaos;
  235.         }
  236.         if (command == "stripes")
  237.         {
  238.             set_stripes();
  239.         }
  240.     }
  241. }
  242.  
  243. //###########################################################################################
  244.  
  245. state invisi
  246. {
  247.     state_entry()
  248.     {
  249.         llSetTimerEvent(0.0);
  250.         MODE = "invisi";
  251.         PROGRESSION = "static";
  252.         llListen(623568, "", llGetOwner(), "");
  253.         llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  254.         llSay(265, "invisi");
  255.         COLOR = <1.0, 1.0, 1.0>;
  256.         llMessageLinked(0, 3, (string)COLOR, NULL_KEY);
  257.         llSetColor(COLOR, 0);
  258.         llSetTexture(INVISI, 0);
  259.     }
  260.     listen(integer channel, string name, key id, string message)
  261.     {
  262.         list parsed = llParseString2List(message, [" "], []);
  263.         string command = llList2String(parsed, 0);
  264.         if ((llList2Float(parsed, 1) > 0.0) && ((command == "linear") || (command == "random") || (command == "step")))
  265.         {
  266.             INTERVAL = llList2Float(parsed, 1);
  267.         }
  268.         if (command == "step")  
  269.         {
  270.             llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  271.         }
  272.         if (command == "linear")
  273.         {
  274.             state default; //linear
  275.         }
  276.         if (command == "solid")
  277.         {
  278.             if (llGetListLength(parsed) == 4)
  279.             {
  280.                 COLOR.x = llList2Float(parsed, 1);
  281.                 COLOR.y = llList2Float(parsed, 2);
  282.                 COLOR.z = llList2Float(parsed, 3);
  283.                 state solid;
  284.             }
  285.             else
  286.             {
  287.                 llSay(2389547, "Please provide 3 values for RGB");
  288.             }
  289.         }
  290.         if (command == "random")
  291.         {
  292.             state random;
  293.         }
  294.         if (command == "chaos")
  295.         {
  296.             state chaos;
  297.         }
  298.     }
  299.     state_exit()
  300.     {
  301.         llSetTexture(TEXTURE_BLANK, 0);
  302.     }
  303. }
  304.  
  305. //###########################################################################################
  306.  
  307. state random
  308. {
  309.     state_entry()
  310.     {
  311.         MODE = "random";
  312.         PROGRESSION = "cycling";
  313.         if (INTERVAL < 2.0) INTERVAL = 2.0;
  314.         llListen(623568, "", llGetOwner(), "");
  315.         llSetTimerEvent(INTERVAL);
  316.         llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  317.     }
  318.     touch_start(integer total_number)
  319.     {
  320.         if (llDetectedKey(0) == llGetOwner())
  321.         {
  322.             if (PROGRESSION == "cycling")
  323.             {
  324.                 llSetTimerEvent(0.0);
  325.                 PROGRESSION = "static";
  326.                 llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  327.             }
  328.             else
  329.             {
  330.                 llSetTimerEvent(INTERVAL);
  331.                 PROGRESSION = "cycling";
  332.                 llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  333.             }
  334.         }
  335.     }
  336.     listen(integer channel, string name, key id, string message)
  337.     {
  338.         list parsed = llParseString2List(message, [" "], []);
  339.         string command = llList2String(parsed, 0);
  340.         if ((llList2Float(parsed, 1) > 0.0) && ((command == "linear") || (command == "random") || (command == "step")))
  341.         {
  342.             INTERVAL = llList2Float(parsed, 1);
  343.             if (INTERVAL < 2.0)
  344.             {
  345.                 INTERVAL = 2.0;
  346.             }
  347.             llSetTimerEvent(INTERVAL);
  348.         }
  349.         if (command == "step")  
  350.         {
  351.             llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  352.         }
  353.         if (command == "linear")
  354.         {
  355.             state default; //linear
  356.         }
  357.         if (command == "solid")
  358.         {
  359.             if (llGetListLength(parsed) == 4)
  360.             {
  361.                 COLOR.x = llList2Float(parsed, 1);
  362.                 COLOR.y = llList2Float(parsed, 2);
  363.                 COLOR.z = llList2Float(parsed, 3);
  364.                 state solid;
  365.             }
  366.             else
  367.             {
  368.                 llSay(2389547, "Please provide 3 values for RGB");
  369.             }
  370.         }
  371.         if (command == "invisi")
  372.         {
  373.             state invisi;
  374.         }
  375.         if (command == "chaos")
  376.         {
  377.             state chaos;
  378.         }
  379.         if (command == "stripes")
  380.         {
  381.             set_stripes();
  382.         }
  383.     }
  384.     timer()
  385.     {
  386.         vector new_color;
  387.         vector color_1;
  388.         vector color_2;
  389.         vector color_3;
  390.         new_color.x = llFrand(1.0);
  391.         new_color.y = llFrand(1.0);
  392.         new_color.z = llFrand(1.0);
  393.         color_2.x = midpoint(COLOR.x, new_color.x);
  394.         color_2.y = midpoint(COLOR.y, new_color.y);
  395.         color_2.z = midpoint(COLOR.z, new_color.z);
  396.         color_1.x = midpoint(COLOR.x, color_2.x);
  397.         color_1.y = midpoint(COLOR.y, color_2.y);
  398.         color_1.z = midpoint(COLOR.z, color_2.z);
  399.         color_3.x = midpoint(color_2.x, new_color.x);
  400.         color_3.y = midpoint(color_2.y, new_color.y);
  401.         color_3.z = midpoint(color_2.z, new_color.z);
  402.         set_colors(color_1);
  403.         set_colors(color_2);
  404.         set_colors(color_3);
  405.         set_colors(new_color);
  406.         COLOR = new_color;
  407.     }
  408. }
  409.  
  410. //###########################################################################################
  411.  
  412. state chaos
  413. {
  414.     state_entry()
  415.     {
  416.         MODE = "chaos";
  417.         INTERVAL = 0.05;
  418.         PROGRESSION = "cycling";
  419.         llListen(623568, "", llGetOwner(), "");
  420.         llSetTimerEvent(INTERVAL);
  421.         llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  422.         llSay(265, "chaos");
  423.         llMessageLinked(0, 3, "chaos", NULL_KEY);
  424.     }
  425.     listen(integer channel, string name, key id, string message)
  426.     {
  427.         list parsed = llParseString2List(message, [" "], []);
  428.         string command = llList2String(parsed, 0);
  429.         if ((llList2Float(parsed, 1) > 0.0) && ((command == "linear") || (command == "random") || (command == "step")))
  430.         {
  431.             INTERVAL = llList2Float(parsed, 1);
  432.         }
  433.         if (command == "step")  
  434.         {
  435.             llSay(2389547, "Color: " + MODE + ", " + PROGRESSION + " at " + (string)INTERVAL + " seconds");
  436.         }
  437.         if (command == "linear")
  438.         {
  439.             state default; //linear
  440.         }
  441.         if (command == "solid")
  442.         {
  443.             if (llGetListLength(parsed) == 4)
  444.             {
  445.                 COLOR.x = llList2Float(parsed, 1);
  446.                 COLOR.y = llList2Float(parsed, 2);
  447.                 COLOR.z = llList2Float(parsed, 3);
  448.                 state solid;
  449.             }
  450.             else
  451.             {
  452.                 llSay(2389547, "Please provide 3 values for RGB");
  453.             }
  454.         }
  455.         if (command == "invisi")
  456.         {
  457.             state invisi;
  458.         }
  459.         if (command == "random")
  460.         {
  461.             state random;
  462.         }
  463.         if (command == "stripes")
  464.         {
  465.             set_stripes();
  466.         }
  467.     }
  468.     timer()
  469.     {
  470.         COLOR.x = llFrand(1.0);
  471.         COLOR.y = llFrand(1.0);
  472.         COLOR.z = llFrand(1.0);
  473.         llSetColor(COLOR, 0);
  474.     }
  475. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement