View Single Post
04-29-09, 12:19 PM   #2
jadakren
A Flamescale Wyrmkin
 
jadakren's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 103
looked at this file yet?

Code:
oUF/elements/tags.lua
to cut names up reliably you will need to include utf8lib and use the functions provided by it.

names like "Smeê" actually turn out to be "Sme\195\170", so without utf8lib you won't get legible operations on extended utf8 characters.

here is the tag i use for my raid frames, while not as complex as yours it may give you a point to start from :

Code:
oUF.Tags["[raidhp]"] = function(u)
    o = ""
    if not(u == nil) then
        local c, m, n= UnitHealth(u), UnitHealthMax(u), UnitName(u)
        if UnitIsDead(u) then
            o = "DEAD"
        elseif not UnitIsConnected(u) then
            o = "D/C"
        elseif UnitIsAFK(u) then
            o = "AFK"
        elseif UnitIsGhost(u) then
            o = "GHOST"
        elseif(c >= m) then
            o = n:utf8sub(1,4)
        elseif(UnitCanAttack("player", u)) then
            o = math.floor(c/m*100+0.5).."%"
        else
            o = "-"..numberize(m - c)
        end
    end
    return o
end
oUF.TagEvents["[raidhp]"] = "UNIT_HEALTH UNIT_MAXHEALTH PLAYER_FLAGS_CHANGED"
here is the function numberize :
Code:
local numberize = function(val)
    if(val >= 1e3) then
        return ("%.1fk"):format(val / 1e3)
    elseif (val >= 1e6) then
        return ("%.1fm"):format(val / 1e6)
    else
        return val
    end
end
This layout file by tekkub will give you an idea on how to implement oUFs tag system :
http://github.com/tekkub/ouf_tek/blo...bea/layout.lua

Last edited by jadakren : 04-29-09 at 12:25 PM.
  Reply With Quote