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!