Hi I am not great with lua and have had a big break from it and now cannot even remember some of the basics.
I want to create an addon that skins the Compact Raid Frame to match my UI better:
I am using the below code to control the addon however it does not show anything when I enter a raid. I am sure there are probably a lot of things wrong with it. Can anyone good at lua show me what I need to change?
Thank you for taking a look at it in advance!
Code:
local MayronUI = ...
local MEDIAPATH = "Interface\\AddOns\\" .. MayronUI .. "\\"
local CLICK = "Interface\\AddOns\\MayronSetup\\Media\\SounD\\click.mp3"
local FONT = "Fonts\\FRIZQT__.ttf"
local classcolor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[(select(2, UnitClass("player")))]
------------------------------------------------------------------------
-- Core Objects and Functions
------------------------------------------------------------------------
local CompactFrame = CreateFrame("Frame", "CompactFrame", UIParent)
CompactFrame:Hide()
local Open = CreateFrame("Button", "Open", UIParent)
Open:Hide()
local Close = CreateFrame("Button", "Close", UIParent)
Close:Hide()
local function OpenFrame()
Open:Hide()
CompactFrame:Show()
end
local function CloseFrame()
Open:Show()
CompactFrame:Hide()
end
local EventFrame = CreateFrame("Frame")
EventFrame:RegisterEvent("PLAYER_ENTER_WORLD")
EventFrame:SetScript("OnEvent", function(self, event, ...)
inInstance, instanceType = IsInInstance()
if IsInInstance() then
if CompactRaidFrameManagerDisplayFrame:IsVisible() then
OpenFrame()
else
CloseFrame()
end
end
end)
------------------------------------------------------------------------
-- OnShow Events
------------------------------------------------------------------------
CompactFrame:SetScript("OnShow", function(self)
self:SetScript("OnShow", nil)
self:SetPoint("TOPLEFT", "CompactRaidFrameManagerDisplayFrame", "TOPLEFT", 0, 0)
self:SetPoint("BOTTOMRIGHT", "CompactRaidFrameManagerDisplayFrame", "BOTTOMRIGHT", 0, 0)
local CompactDisplay = self:CreateTexture(nil, "BORDER")
CompactDisplay:SetPoint("TOPLEFT", "CompactRaidFrameManagerDisplayFrame", "TOPLEFT", 0, 0)
CompactDisplay:SetPoint("BOTTOMRIGHT", "CompactRaidFrameManagerDisplayFrame", "BOTTOMRIGHT", 0, 0)
CompactDisplay:SetBackdropColor(0.2,0.2,0.2,0.8)
CloseFrame:SetPoint("LEFT", "CompactFrame", "RIGHT", 0, 0)
CloseFrame:SetText("<")
CloseFrame:CreateTexture(nil, "BORDER")
CloseFrame:SetBackdropColor(0.2,0.2,0.2,0.8)
CloseFrame:SetTextColor(classcolor.r, classcolor.g, classcolor.b)
CloseFrame:SetTexture(MEDIAPATH .. "RightBarButton")
CloseFrame:SetScript("OnClick", function()
PlaySoundFile(CLICK)
CloseFrame()
end)
CloseFrame:SetScript("OnEnter", function()
local _, class = UnitClass("player");
if class == "PRIEST" then
CloseFrame:SetTextColor(1,0,0)
else
CloseFrame:SetTextColor(1,1,1)
end
end)
CloseFrame:SetScript("OnLeave", function()
CloseFrame:SetTextColor(classcolor.r, classcolor.g, classcolor.b)
end)
Open:SetScript("OnShow", function(self)
self:SetScript("OnShow", nil)
self:SetPoint("CENTER", "UIParent", "CENTER", 0, 0)
self:CreateTexture(nil, "HIGH")
self:SetBackdropColor(0.2,0.2,0.2,0.8)
local OpenText = self:CreateFontString(nil, "HIGH")
OpenText:SetFont(FONT, 14)
OpenText:SetTextColor(classcolor.r, classcolor.g, classcolor.b)
OpenText:SetText(">")
self:SetNormalTexture(MEDIAPATH .. "RightBarButton")
self:SetScript("OnClick", function()
PlaySoundFile(CLICK)
OpenFrame()
end)
self:SetScript("OnEnter", function()
local _, class = UnitClass("player");
if class == "PRIEST" then
self:SetTextColor(1,0,0)
else
self:SetTextColor(1,1,1)
end
end)
self:SetScript("OnLeave", function()
self:SetTextColor(classcolor.r, classcolor.g, classcolor.b)
end)
end)