Jump to content

Kyric Leakey

Resident
  • Posts

    6
  • Joined

  • Last visited

Reputation

3 Neutral
  1. It is I guess? because it's listening to the other events inside the same block on 88
  2. Hello again, I've got my script somewhat to where I want but I have an issue now where it just won't change the color when listening on command /88 integer MAX_HEARTS = 4; // Maximum number of hearts integer currentHearts = MAX_HEARTS; // Initial number of hearts vector textColor = <1.0, 0.0, 0.0>; // Initial text color (red) // Function to update the health bar display updateHealthBar() { string displayText = ""; string hpText = "HP " + (string)currentHearts + "/" + (string)MAX_HEARTS + "\n"; // HP text integer i; // Check if hearts are all gone if (currentHearts <= 0) { llSetText("BEWUSSTLOS", textColor, 1.5); // Change text color return; } // Construct the display text with hearts for (i = 0; i < currentHearts; i++) { displayText += "♥ "; // Add the heart symbol } // Display the hearts as floating text above the object llSetText(hpText + "\n" + displayText, textColor, 1.5); // Change text color, display HP text and hearts } default { state_entry() { // Display initial health bar updateHealthBar(); // Listen for channel 88 llListen(88, "", "", ""); } touch_start(integer total_number) { // Reduce the number of hearts when clicked if (currentHearts > 0) { currentHearts--; // Update the displayed hearts updateHealthBar(); } else { llSetText("BEWUSSTLOS", textColor, 1.5); // Change text color } } listen(integer channel, string name, key id, string message) { // Check if the message is for color change and sender is the owner if (llGetSubString(message, 0, 0) == "/" && llGetOwner() == id) { list parts = llParseString2List(message, ["<", ",", ">"], []); if (llGetListLength(parts) == 4) { float r = (float)llList2String(parts, 1) / 255.0; float g = (float)llList2String(parts, 2) / 255.0; float b = (float)llList2String(parts, 3) / 255.0; textColor = <r, g, b>; updateHealthBar(); // Update the displayed health bar with the new text color } } else if (message == "PlusButtonClicked") { if (currentHearts < MAX_HEARTS) { currentHearts++; // Update the displayed hearts updateHealthBar(); } } else if (message == "MinusButtonClicked") { if (currentHearts > 0) { currentHearts--; // Update the displayed hearts updateHealthBar(); } } else if (message == "ResetButtonClicked") { // Reset the health bar to max hearts currentHearts = MAX_HEARTS; // Update the displayed hearts updateHealthBar(); } } } Hope someone can spot the issue. Thank you in advanced!
  3. Thank you for the quick reply, really appreciated. That did indeed fix the syntax error, unfortunately it looks like the object is not listening properly to the events, nothing happens. But glad I got passed the syntax, now there is something else going on.
  4. Hey guys, I tried a lot but I can't seem to get around this issue, I am not an LSL expert but I can't find a syntax error here: So i am trying to create a Health-bar for Roleplay purposes and sending llRegionSay events from a HUD attached object on touch_start Here's a button example: // Plus Button Script default { touch_start(integer total_number) { llSay(0, "Sending PlusButtonClicked message..."); llRegionSay(88, "PlusButtonClicked"); } } And Here's the Health-bar: integer MAX_HEARTS = 4; // Maximum number of hearts integer currentHearts = MAX_HEARTS; // Initial number of hearts default { state_entry() { // Display initial health bar updateHealthBar(); // Listen for button events llListen(88, "", "", ""); } touch_start(integer total_number) { // Reduce the number of hearts when clicked if (currentHearts > 0) { currentHearts--; // Update the displayed hearts updateHealthBar(); } else { llSetText("Bewusstlos", <1.0, 1.0, 1.0>, 1.0); llResetScript(); // Reset the script if all hearts are gone } } listen(integer channel, string name, key id, string message) { if (message == "PlusButtonClicked") { if (currentHearts < MAX_HEARTS) { currentHearts++; // Update the displayed hearts updateHealthBar(); } } else if (message == "MinusButtonClicked") { if (currentHearts > 0) { currentHearts--; // Update the displayed hearts updateHealthBar(); } } } // Function to update the health bar display updateHealthBar() { string displayText = ""; integer i; // Check if hearts are all gone if (currentHearts <= 0) { llSetText("Bewusstlos", <1.0, 1.0, 1.0>, 1.0); return; } // Construct the display text with hearts for (i = 0; i < currentHearts; i++) { displayText += "<3>"; // Use the heart symbol } // Display the hearts on the object llSetText(displayText, <1.0, 1.0, 1.0>, 1.0); } // End of updateHealthBar function } // End of default state Line 53 keeps giving me the Syntax error for updateHealthBar() Hope anyone can help, thank you in advanced!!
×
×
  • Create New...