I don't know what, specifically, was wrong with your code, but I ended up just rewriting it from scratch, and this works flawlessly. I included some comments to indicate where to insert calls to your backdrop and border functions if you want.
Code:
local factions = { 1341, 1269, 1270, 1337, 1359 }
local bars = {}
-- Feel free to remove this and replace it with your backdrop function:
local BACKDROP = {
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tile = true, tileSize = 16,
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
insets = { left = 5, right = 5, top = 5, right = 5 },
}
local function OnEvent(self, event, ...)
local name, _, standing, barMin, barMax, barValue = GetFactionInfoByID(self.factionID)
self:SetMinMaxValues(barMin, barMax)
self:SetValue(barValue)
local color = FACTION_BAR_COLORS[standing]
self:SetStatusBarColor(color.r, color.g, color.b)
self.text:SetText(name)
if standing == 8 then
self.text:SetTextColor(1, 0.6, 0.33)
else
self.text:SetTextColor(1, 1, 1)
end
end
-- Feel free to remove this function if you don't want mouse interactivity:
local function OnEnter(self)
local _, _, _, barMin, barMax, barValue = GetFactionInfoByID(self.factionID)
self.text:SetFormattedText("%d/%d", barValue - barMin, barMax - barMin)
end
-- Feel free to remove this function if you don't want mouse interactivity:
local function OnLeave(self)
local name = GetFactionInfoByID(self.factionID)
self.text:SetText(name)
end
for i, factionID in ipairs(factions) do
local bar = CreateFrame("StatusBar", nil, UIParent)
bar:SetPoint("TOP", i>1 and bars[i-1] or Minimap, "BOTTOM", 0, i>1 and -8 or -24)
bar:SetSize(162, 14)
bars[i] = bar
-- Feel free to remove this section and replace it with a call to your backdrop function:
local bg = bar:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints(true)
bg:SetTexture(0, 0, 0, 0.7)
bar.bg = bg
bar:SetStatusBarTexture([[Interface/TargetingFrame/UI-StatusBar]])
bar:GetStatusBarTexture():SetDrawLayer("BORDER")
-- Feel free to remove this section and replace it with a call to your border function
local left = bar:CreateTexture(nil, "ARTWORK")
left:SetTexture([[Interface\AchievementFrame\UI-Achievement-ProgressBar-Border]])
left:SetTexCoord(0, 0.0625, 0, 0.75)
left:SetPoint("TOPLEFT", -6, 5)
left:SetPoint("BOTTOMLEFT", -6, -5)
left:SetWidth(16)
bar.left = left
local right = bar:CreateTexture(nil, "ARTWORK")
right:SetTexture([[Interface\AchievementFrame\UI-Achievement-ProgressBar-Border]])
right:SetTexCoord(0.812, 0.8745, 0, 0.75)
right:SetPoint("TOPRIGHT", 6, 5)
right:SetPoint("BOTTOMRIGHT", 6, -5)
right:SetWidth(16)
bar.right = right
local center = bar:CreateTexture(nil, "ARTWORK")
center:SetTexture([[Interface\AchievementFrame\UI-Achievement-ProgressBar-Border]])
center:SetTexCoord(0.0625, 0.812, 0, 0.75)
center:SetPoint("TOPLEFT", left, "TOPRIGHT")
center:SetPoint("BOTTOMRIGHT", right, "BOTTOMLEFT")
center:SetWidth(16)
bar.center = center
-- End of border section
local text = bar:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
text:SetPoint("CENTER")
bar.text = text
bar.factionID = factionID
bar:SetScript("OnEvent", OnEvent)
bar:RegisterEvent("UPDATE_FACTION")
-- Feel free to remove this section if you don't want mouse interactivity:
bar:EnableMouse(true)
bar:SetScript("OnEnter", OnEnter)
bar:SetScript("OnLeave", OnLeave)
end