1. #1

    Combining two lua codes

    Both of these work, but I'd like to combine them all into one.

    First one changes class colour text:

    local r,g,b = ClassColor(unit)
    return '|cff%02x%02x%02x%s|r %s%s%s',r,g,b,Name(unit),Angle(AFK(unit) or DND(unit))

    Second one shortens long names into an abbreviated form on healthbars:

    local abbr = Name(unit)
    if abbr:len() > 20 and abbr:find(" ") then
    abbr = abbr:gsub("([^ ]+) +",
    function(text)
    return text:sub(1,1) .. ". "
    end)
    end
    return "%s", abbr;

    How can I combine these, so that both functions work as one entry? If it helps, I'm using pitbull.

  2. #2
    Field Marshal nebula's Avatar
    10+ Year Old Account
    Join Date
    Jul 2009
    Location
    Minnesota
    Posts
    88
    Put the second bit of code first, then replace the Name(unit) with abbr


    local abbr = Name(unit)
    if abbr:len() > 20 and abbr:find(" ") then
    abbr = abbr:gsub("([^ ]+) +", function(text)
    return text:sub(1,1) .. ". "
    end)
    end
    local r,g,b = ClassColor(unit)
    return '|cff%02x%02x%02x%s|r %s%s%s',r,g,b,abbr,Angle(AFK(unit) or DND(unit))

  3. #3
    Quote Originally Posted by nebula View Post
    Put the second bit of code first, then replace the Name(unit) with abbr


    local abbr = Name(unit)
    if abbr:len() > 20 and abbr:find(" ") then
    abbr = abbr:gsub("([^ ]+) +", function(text)
    return text:sub(1,1) .. ". "
    end)
    end
    local r,g,b = ClassColor(unit)
    return '|cff%02x%02x%02x%s|r %s%s%s',r,g,b,abbr,Angle(AFK(unit) or DND(unit))
    imgur.com/L8k8pjg (As I'm a new poster, I'm not allowed to post images yet, but here it is in all it's functioning beauty)

    Thank you SO VERY MUCH!! <3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •