Kyric Leakey Posted March 5 Share Posted March 5 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! Link to comment Share on other sites More sharing options...
SarahKB7 Koskinen Posted March 5 Share Posted March 5 listen(integer channel, string name, key id, string message) integer channel not set to listen to 88 ? Link to comment Share on other sites More sharing options...
Kyric Leakey Posted March 5 Author Share Posted March 5 It is I guess? because it's listening to the other events inside the same block on 88 Link to comment Share on other sites More sharing options...
Love Zhaoying Posted March 5 Share Posted March 5 I suggest when your code gets to the point where you are trying to change the color, you use llSay() to output a debug message - and make sure the code reaches that point, etc. For example: 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>; // Add some debug info here - show the code actually got here and the new textColor value llSay(0, "Setting new textColor=" + (string)textColor); updateHealthBar(); // Update the displayed health bar with the new text color } } Link to comment Share on other sites More sharing options...
Kyric Leakey Posted March 5 Author Share Posted March 5 okay got it fixed 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now