Hello, I'm looking for a little help in understanding why this code does not successfully change the default exp status bar color:
lua Code:
hooksecurefunc("ExhaustionTick_OnEvent", function(self, event, ...)
MainMenuExpBar:SetStatusBarColor(1, 1, 1, 1)
end);
Also tried:
lua Code:
hooksecurefunc("ExhaustionTick_OnEvent", function(self, event, ...)
MainMenuExpBar:SetStatusBarColor(1, 1, 1, 1)
if (exhaustionStateID == 1) or (exhaustionStateID == 2) then
MainMenuExpBar:SetStatusBarColor(1, 1, 1, 1)
end
end);
Below is the full function from Blizzard's MainMenuBar.lua. For giggles I used the whole thing in my hooksecurefunc() to no avail...I'm not seeing the SetStatusBarColor() values being applied. I appreciate any thoughts.
lua Code:
function ExhaustionTick_OnEvent(self, event, ...)
if ((event == "PLAYER_ENTERING_WORLD") or (event == "PLAYER_XP_UPDATE") or (event == "UPDATE_EXHAUSTION") or (event == "PLAYER_LEVEL_UP")) then
local playerCurrXP = UnitXP("player");
local playerMaxXP = UnitXPMax("player");
--local exhaustionCurrXP, exhaustionMaxXP;
--exhaustionCurrXP, exhaustionMaxXP = GetXPExhaustion();
local exhaustionThreshold = GetXPExhaustion();
local exhaustionStateID, exhaustionStateName, exhaustionStateMultiplier;
exhaustionStateID, exhaustionStateName, exhaustionStateMultiplier = GetRestState();
if (exhaustionStateID >= 3) then
ExhaustionTick:SetPoint("CENTER", "MainMenuExpBar", "RIGHT", 0, 0);
end
if (not exhaustionThreshold) then
ExhaustionTick:Hide();
ExhaustionLevelFillBar:Hide();
else
local exhaustionTickSet = max(((playerCurrXP + exhaustionThreshold) / playerMaxXP) * MainMenuExpBar:GetWidth(), 0);
-- local exhaustionTotalXP = playerCurrXP + (exhaustionMaxXP - exhaustionCurrXP);
-- local exhaustionTickSet = (exhaustionTotalXP / playerMaxXP) * MainMenuExpBar:GetWidth();
ExhaustionTick:ClearAllPoints();
if (exhaustionTickSet > MainMenuExpBar:GetWidth() or MainMenuBarMaxLevelBar:IsShown()) then
ExhaustionTick:Hide();
ExhaustionLevelFillBar:Hide();
-- Saving this code in case we want to always leave the exhaustion tick onscreen
-- ExhaustionTick:SetPoint("CENTER", "MainMenuExpBar", "RIGHT", 0, 0);
-- ExhaustionLevelFillBar:SetPoint("TOPRIGHT", "MainMenuExpBar", "TOPRIGHT", 0, 0);
else
ExhaustionTick:Show();
ExhaustionTick:SetPoint("CENTER", "MainMenuExpBar", "LEFT", exhaustionTickSet, 0);
ExhaustionLevelFillBar:Show();
ExhaustionLevelFillBar:SetPoint("TOPRIGHT", "MainMenuExpBar", "TOPLEFT", exhaustionTickSet, 0);
end
end
-- Hide exhaustion tick if player is max level or XP is turned off
if ( UnitLevel("player") == MAX_PLAYER_LEVEL or IsXPUserDisabled() ) then
ExhaustionTick:Hide();
end
end
if ((event == "PLAYER_ENTERING_WORLD") or (event == "UPDATE_EXHAUSTION")) then
local exhaustionStateID = GetRestState();
if (exhaustionStateID == 1) then
MainMenuExpBar:SetStatusBarColor(0.0, 0.39, 0.88, 1.0);
ExhaustionLevelFillBar:SetVertexColor(0.0, 0.39, 0.88, 0.15);
ExhaustionTickHighlight:SetVertexColor(0.0, 0.39, 0.88);
elseif (exhaustionStateID == 2) then
MainMenuExpBar:SetStatusBarColor(0.58, 0.0, 0.55, 1.0);
ExhaustionLevelFillBar:SetVertexColor(0.58, 0.0, 0.55, 0.15);
ExhaustionTickHighlight:SetVertexColor(0.58, 0.0, 0.55);
end
end
if ( not MainMenuExpBar:IsShown() ) then
ExhaustionTick:Hide();
end
end