I am trying to replace text on the reputation bar. The current text looks like the following, but of course the number and status change with each watched faction update.
Code:
Valajar: 7.5K [Exalted]
What I would like to do is replace the
[Exalted] portion with
Paragon if the faction is paragon-level.
This is what I have so far.
Lua Code:
if isParagon then
local replacement = ""
local barText = bar.text:GetText()
local gender = UnitSex("player")
local exalted = GetText("FACTION_STANDING_LABEL" .. standingID, gender)
print("My standing is ", exalted)
if E.db.PCB.reputationBar.textFormat == "P" then
replacement = L["P"]
else
replacement = L["Paragon"]
end
local match = strmatch(barText, "^%[(.+)%]")
print("My match is ", match)
--[[
barText = string.gsub(barText, "^%[" .. ("%w+"), replacement)
barText = string.gsub(barText, "%[", "")
barText = string.gsub(barText, "%]", "")
bar.text:SetText(barText)
]]--
end
Sure enough, the first test print does say "My standing is Exalted" only if the watched rep is Paragon, but the second test print outputs "My match is nil" so it isn't matching anything. If I could get it to work, the end result would look like the below for Paragon factions. For every other faction it should still say whatever text is on the rep bar by default. This also means that if a faction is Paragon-capable yet the user has not gained Paragon status it should still say [Revered] or whatever.
Code:
Valajar: 7.5K Paragon