I'm trying to create a text pattern for my stuf frames that would show a percentage of mana with the added exact amounts depending on whether the amount of mana is at max or not.
For example:
100% - 20000
or
80% - 16000 / 20000
Originally I simply had this as the input:
Code:
[percmp]%[solid_if_mp99: - ][solid_if_mp99:curmp][solid_if_mp99: / ][solid_if_mp99:maxmp]
However there's no conditional I can put to only display something when the mana is at full to add the additional max mana.
So I started working on an Lua version here:
Code:
function(unit, cache, textframe)
local mp,mpmax = UnitPower(unit),UnitPowerMax(unit)
local pctmp = floor(100*(mp/mpmax))
local text
local function truncate(value)
if value >= 1e6 then
return format('%.1fm', value / 1e6)
elseif value >= 1e4 then
return format('%.1fk', value / 1e3)
else
return value
end
end
if mp == mpmax then
text = pctmp.."%"
else
text = pctmp.."% "..truncate(mp).." / "..truncate(mpmax)
end
return text
end
This should be working as written however I get this error:
Code:
1x Stuf-3.3.006\text.lua:102: invalid option in `format'
Lines for text.lua 102:
Code:
local function AddAdvanceText(fs, a1, ...)
fs:SetFormattedText(gsub(a1 or "", "||", "|"), ...)
end
"text" does return the proper string, am I missing something?