I appreciate all the replies...
Originally Posted by Haleth
@ OP; In your second attempt, you refer to exhaustionStateID without defining it. Local values are not
inherited from hooked functions.
Try it when you define it as GetRestState(), as the original Blizzard function does.
|
Thanks, this is good to know. When I "For giggles I used the whole thing in my hooksecurefunc()" the definition was there (but I didn't know it needed to be defined there
):
lua Code:
hooksecurefunc("ExhaustionTick_OnEvent", function(self, event, ...)
local exhaustionStateID = GetRestState();
if (exhaustionStateID == 1) then
MainMenuExpBar:SetStatusBarColor(0, 1, 0);
ExhaustionLevelFillBar:SetVertexColor(0, 1, 0, .2);
ExhaustionTickHighlight:SetVertexColor(0, 1, 0);
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)
Originally Posted by SDPhantom
Here's a clip of MainMenuBar.xml...
xml Code:
<Button name="ExhaustionTick" parent="MainMenuExpBar" hidden="false" frameStrata="DIALOG"> <Size> <AbsDimension x="32" y="32"/> </Size> <Anchors> <Anchor point="CENTER" relativeTo="MainMenuExpBar"> <Offset> <AbsDimension x="0" y="0"/> </Offset> </Anchor> </Anchors> <Scripts> <OnLoad function="ExhaustionTick_OnLoad"/> <OnEvent function="ExhaustionTick_OnEvent"/> <OnEnter function="ExhaustionToolTipText"/> <OnLeave function="GameTooltip_Hide"/> </Scripts> <NormalTexture name="ExhaustionTickNormal" file="Interface\MainMenuBar\UI-ExhaustionTickNormal"/> <HighlightTexture name="ExhaustionTickHighlight" file="Interface\MainMenuBar\UI-ExhaustionTickHighlight" alphaMode="ADD"/> </Button>
Notice the way the script functions are registered. This grabs the function immediately and sets it to the associated
script. hooksecurefunc() will not work on this. You'll have to hook the frame's script handler directly with
something like this.
lua Code:
ExhaustionTick:HookScript("OnEvent",function(self,event,...) MainMenuExpBar:SetStatusBarColor(1,1,1,1); end);
Your code is conflicting with Blizzards and the event API will randomly choose which it'll fire the event first for. This
one seems to actually be called instead of set as a script handler, so hooksecurefunc() will work on this one.
lua Code:
hooksecurefunc("ReputationWatchBar_Update",function() ReputationWatchStatusBar:SetStatusBarColor(1,1,1,1); end);
|
This is good info, and both code examples work perfectly.
Originally Posted by Mischback
Could you "noop" the original function?
Code:
local function noop()
return
end
MainMenuExpBar:SetStatusBarColor(1, 1, 1, 1)
MainMenuExpBar.SetStatusBarColor = noop
|
This also works perfectly.
So is return nothing just putting the kibosh on any subsequent SetStatusBarColor attempts from Blizzard?
Both methods acheive the desired result...