Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
- // Version 2, December 2004
- //
- // Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
- //
- // Everyone is permitted to copy and distribute verbatim or modified
- // copies of this license document, and changing it is allowed as long
- // as the name is changed.
- //
- // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
- // TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- //
- // 0. You just DO WHAT THE FUCK YOU WANT TO.
- // {Azureus} Simple Heart Titler
- //
- // By Siphon ( @siphon on Telegram )
- // V0.0.1
- ///////////////////////////////
- //// Customizable Settings ////
- ///////////////////////////////
- // Heart ASCII symbol
- string HEART = "♥";
- // Hollow heart ASCII symbol
- string UNHEART = "♡";
- // How many hearts you want
- integer MAX_HEART = 6;
- // Speed to change color, and twice as long as that for updating hearts
- float SPEED = 0.2;
- // Transparent text? Probably leave this alone.
- float TEXT_ALPHA = 1.0;
- // Modify colors as you please. Add or remove them. Watch the commas.
- list COLOR_LIST = [
- <0.983, 0.38, 0.3> // red
- ,<0.978, 0.601, 0.326> // orange
- ,<0.980, 0.949, 0.514> // yellow
- ,<0.649, 0.980, 0.514> // green
- ,<0.518, 0.525, 0.976> // blue
- ,<0.615, 0.513, 0.981> // indigo
- ,<0.918, 0.519, 0.975> // violet
- ];
- ///////////////////////////////////////
- //// WARNING ////
- //// Don't touch beyond this point ////
- ///////////////////////////////////////
- // Initialization. Probably don't touch these
- integer COLOR_LIST_LENGTH = 0;
- integer INCREMENTING = TRUE;
- // Render the health bar based on a single value
- string renderHealth(integer health) {
- string renderedText;
- integer i = 0;
- integer renderedTextLength;
- // Add hearts
- for (i = 0; i <= health - 1; i++) {
- renderedText += HEART;
- }
- // Count the length of the string only once for faster for loops
- integer emptyHearts = MAX_HEART - llStringLength(renderedText) - 1;
- // Add empty hearts
- for (i = 0; i <= emptyHearts; i++) {
- renderedText += UNHEART;
- }
- return renderedText;
- }
- // Basic bitch picking an element from a list
- vector chooseColor(integer index) {
- vector chosenColor = llList2Vector(COLOR_LIST, index);
- return chosenColor;
- }
- // bounds checking I guess
- integer incrementColorIndex(integer index) {
- index++;
- if (index >= llGetListLength(COLOR_LIST)) {
- index = 0;
- }
- return index;
- }
- // Because everyone needs a void main()
- main() {
- COLOR_LIST_LENGTH = llGetListLength(COLOR_LIST);
- // local var initialization
- integer currentHealth = MAX_HEART;
- integer currentColorIndex = 0;
- do {
- // Set the text once
- llSetText(renderHealth(currentHealth), chooseColor(currentColorIndex), TEXT_ALPHA);
- // update our color
- currentColorIndex = incrementColorIndex(currentColorIndex);
- // sleep once
- llSleep(SPEED);
- // Update the color of the text
- llSetText(renderHealth(currentHealth), chooseColor(currentColorIndex), TEXT_ALPHA);
- // Update our color again
- currentColorIndex = incrementColorIndex(currentColorIndex);
- // Basic bitch bounds checking for 'breathing' effect
- if (INCREMENTING) {
- currentHealth++;
- if (currentHealth >= MAX_HEART) {
- INCREMENTING = FALSE;
- currentHealth = MAX_HEART;
- }
- } else {
- currentHealth--;
- if (currentHealth <= 0) {
- INCREMENTING = TRUE;
- currentHealth = 0;
- }
- }
- // Final sleep for the loop
- llSleep(SPEED);
- } while (0 == 0);
- }
- // Fuck states
- default
- {
- // Fuck states
- state_entry()
- {
- // main() all the way, bitch
- main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement