SHARE
TWEET

Untitled

a guest Jan 15th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  2. //                    Version 2, December 2004
  3. //
  4. // Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // Everyone is permitted to copy and distribute verbatim or modified
  7. // copies of this license document, and changing it is allowed as long
  8. // as the name is changed.
  9. //
  10. //            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  11. //   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  12. //
  13. //  0. You just DO WHAT THE FUCK YOU WANT TO.
  14.  
  15. // {Azureus} Simple Heart Titler
  16. //
  17. // By Siphon ( @siphon on Telegram )
  18. // V0.0.1
  19.  
  20.  
  21. ///////////////////////////////
  22. //// Customizable Settings ////
  23. ///////////////////////////////
  24. // Heart ASCII symbol
  25. string HEART = "♥";
  26. // Hollow heart ASCII symbol
  27. string UNHEART = "♡";
  28. // How many hearts you want
  29. integer MAX_HEART = 6;
  30. // Speed to change color, and twice as long as that for updating hearts
  31. float SPEED = 0.2;
  32. // Transparent text? Probably leave this alone.
  33. float TEXT_ALPHA = 1.0;
  34. // Modify colors as you please. Add or remove them. Watch the commas.
  35. list COLOR_LIST = [
  36.     <0.983, 0.38, 0.3>       // red
  37.     ,<0.978, 0.601, 0.326>   // orange
  38.     ,<0.980, 0.949, 0.514>   // yellow
  39.     ,<0.649, 0.980, 0.514>   // green
  40.     ,<0.518, 0.525, 0.976>   // blue
  41.     ,<0.615, 0.513, 0.981>   // indigo
  42.     ,<0.918, 0.519, 0.975>   // violet
  43. ];
  44.  
  45. ///////////////////////////////////////
  46. ////            WARNING            ////
  47. //// Don't touch beyond this point ////
  48. ///////////////////////////////////////
  49. // Initialization. Probably don't touch these
  50. integer COLOR_LIST_LENGTH = 0;
  51. integer INCREMENTING = TRUE;
  52.  
  53. // Render the health bar based on a single value
  54. string renderHealth(integer health) {
  55.     string renderedText;
  56.     integer i = 0;
  57.     integer renderedTextLength;
  58.  
  59.     // Add hearts
  60.     for (i = 0; i <= health - 1; i++) {
  61.         renderedText += HEART;
  62.     }
  63.  
  64.     // Count the length of the string only once for faster for loops
  65.     integer emptyHearts = MAX_HEART - llStringLength(renderedText) - 1;
  66.  
  67.     // Add empty hearts
  68.     for (i = 0; i <= emptyHearts; i++) {
  69.         renderedText += UNHEART;
  70.     }
  71.  
  72.     return renderedText;
  73. }
  74.  
  75. // Basic bitch picking an element from a list
  76. vector chooseColor(integer index) {
  77.    vector chosenColor = llList2Vector(COLOR_LIST, index);
  78.    return chosenColor;
  79. }
  80.  
  81. // bounds checking I guess
  82. integer incrementColorIndex(integer index) {
  83.     index++;
  84.     if (index >= llGetListLength(COLOR_LIST)) {
  85.         index = 0;
  86.     }
  87.     return index;
  88. }
  89.  
  90. // Because everyone needs a void main()
  91. main() {
  92.     COLOR_LIST_LENGTH = llGetListLength(COLOR_LIST);
  93.  
  94.     // local var initialization
  95.     integer currentHealth = MAX_HEART;
  96.     integer currentColorIndex = 0;
  97.  
  98.     do {
  99.         // Set the text once
  100.         llSetText(renderHealth(currentHealth), chooseColor(currentColorIndex), TEXT_ALPHA);
  101.  
  102.         // update our color
  103.         currentColorIndex = incrementColorIndex(currentColorIndex);
  104.  
  105.         // sleep once
  106.         llSleep(SPEED);
  107.  
  108.         // Update the color of the text
  109.         llSetText(renderHealth(currentHealth), chooseColor(currentColorIndex), TEXT_ALPHA);
  110.  
  111.         // Update our color again
  112.         currentColorIndex = incrementColorIndex(currentColorIndex);
  113.  
  114.         // Basic bitch bounds checking for 'breathing' effect
  115.         if (INCREMENTING) {
  116.             currentHealth++;
  117.             if (currentHealth >= MAX_HEART) {
  118.                 INCREMENTING = FALSE;
  119.                 currentHealth = MAX_HEART;
  120.             }
  121.         } else {
  122.             currentHealth--;
  123.             if (currentHealth <= 0) {
  124.                 INCREMENTING = TRUE;
  125.                 currentHealth = 0;
  126.             }
  127.         }
  128.  
  129.         // Final sleep for the loop
  130.         llSleep(SPEED);
  131.  
  132.     } while (0 == 0);
  133. }
  134.  
  135. // Fuck states
  136. default
  137. {
  138.     // Fuck states
  139.     state_entry()
  140.     {
  141.         // main() all the way, bitch
  142.         main();
  143.     }
  144. }
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
 
Top