So I'm attempting to "rewrite" a global function for Grid, since I generally rewrite it for my own usage:
Original Function:
Code:
function GridFrame.prototype:SetBarColor(r, g, b, a)
if GridFrame.db.profile.invertBarColor then
self.Bar:SetStatusBarColor(r, g, b, a)
self.BarBG:SetVertexColor(r * 0.2, g * 0.2, b * 0.2, 1)
else
self.Bar:SetStatusBarColor(0, 0, 0, 0.8)
self.BarBG:SetVertexColor(r, g, b, a)
end
self:UpdateHealingBarColor()
end
I've looked over the API page regarding hooksecurefunc on wowwiki but I'm not sure exactly how to go about this particular function.
Could anyone show me how I can "rewrite" this function to my liking with a hooksecure?
What I've come up with:
Code:
local function GridFix(r, g, b, a)
--do stuff
print("Stuff Done!")
end
local f = CreateFrame"Frame"
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", function(self,event,...)
local arg1 = ...
if arg1 == "Grid" then
hooksecurefunc(GridFrame.prototype:SetBarColor(r, g, b, a), GridFix(r,g,b,a))
end
end)