1. #1
    Deleted

    Weak Auras, abbreviate to thousands

    Hey guys,

    I'm trying to make what I thought was a very simple little aura. It should simply show my health as text, similar to this:

    250K/300K (or however much health I have)

    The problem is that little K at the end. I CAN NOT find how to abbreviate the numbers in Weak Auras. I even tried making my own custom LUA function, using snippets I found online, but couldn't get that to work either.

    Anyone know how to do this?

    Thanks

  2. #2
    Deleted
    Custom Text (%c):

    Code:
    function()
        return ("%.0fk / %.0fk"):format(UnitHealth("player") / 1000, UnitHealthMax("player") / 1000)
    end
    If you want decimals (250.4k / 300.9k, for example) just use %.01fk in both places (1 being the number of decimals)
    Last edited by mmoca821fe2863; 2013-02-17 at 12:40 AM.

  3. #3
    Deleted
    Thanks mate! Worked great!
    Strange this is not a built in feature in Weak Auras normal settings though, would have made it easier for people

    In any case, thanks allot!

  4. #4

    Weak Aura Abbreviated HP?

    I may be taking crazy pills here.. but I am trying to find the abbreviation for weakauras to show me the health abbreviation (for k and m) without the /482k or whatever at the end. What would be the code for that. For the life of me, I cannot find it anywhere on the internet as it appears I am the only one who doesn't want this blank out of blank format... can anyone help me?

    So for instance, I would want 432,039 to show up as 432k.
    I would want 43,938,244 to show up as 43m.

    Also, Is it possible to have the top text as a custom text and the bottom text as a different custom text? If so, where is the other box?
    Last edited by silvercued; 2013-10-22 at 05:51 PM.

  5. #5
    Deleted
    Quote Originally Posted by silvercued View Post
    So for instance, I would want 432,039 to show up as 432k.
    I would want 43,938,244 to show up as 43m.
    Assuming you're talking about target hp:
    Code:
    function()
        local health = UnitHealth("target")
        local abbr = ""
        if health >= 1000 then
            health = health / 1000
            abbr = "k"
        end
        if health >= 1000 then
            health = health / 1000
            abbr = "m"
        end
        
        return ("%.0f%s"):format(health, abbr)
    end

  6. #6
    Dreadlord GoKs's Avatar
    10+ Year Old Account
    Join Date
    May 2013
    Location
    South Africa
    Posts
    869
    Since we are on the topic of health and WA2 here, I would appreciate it if someone could tell me how to add a bar to show how much % of health my target has?
    I am a hunter and I use this WA2 mod : http://www.mmo-champion.com/threads/...ter-Aura-Group!. It is really great, just missing a bar for the health %, it would even help if the % of HP is displayed on the focusbar (like JSHB).?

  7. #7
    Quote Originally Posted by ccKep View Post
    Custom Text (%c):

    Code:
    function()
        return ("%.0fk / %.0fk"):format(UnitHealth("player") / 1000, UnitHealthMax("player") / 1000)
    end
    If you want decimals (250.4k / 300.9k, for example) just use %.01fk in both places (1 being the number of decimals)
    How would you change this function to show total mana? I am using frames that are less than perfect for knowing the amount of mana I have available, but am working on getting them to be better. Until then, getting a function for the mana bar I have that would show totals instead of the % of mana would be fantastic. =|

    Thanks in advance.

  8. #8
    Replace both instances of Health with Mana (case sensitive).
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  9. #9
    Deleted
    I know this is a bit old, but I was wondering how to mix both functions into a single one. One where the numbers are abbreviated depending on a specific amount (or several, like the example above), and also compares current health with max health.

    This is what I've got so far but it is not working:
    Code:
    function()
        local hp = UnitHealth("player")
        local max = UnitHealthMax("player")
        local abb = ""
        
        if hp > 999 then
            hp = hp / 1000
            abb = "m"
        end
        
        if max > 999 then
            max = max / 1000
            abb = "m"
        end
        
        return ("%.0f/%.0f"):format(hp, abb / max, abb)
    end
    Basically I want to see 518/518 when the numbers are below 1000, and 14m/14m when they are over 999. I guess knowing this structure, I will be able to add more variables if needed.

    Thanks!
    Last edited by mmocb161201a0e; 2017-11-05 at 12:15 PM.

  10. #10
    Quote Originally Posted by karvo1023 View Post
    I know this is a bit old, but I was wondering how to mix both functions into a single one. One where the numbers are abbreviated depending on a specific amount (or several, like the example above), and also compares current health with max health.
    If you wanted to format both hp and hpmax you should make double checks (for "k" and "m") for both of them.

    Alternatively you could use subfunction to format string and then use it for both hp and hpmax, something like this:
    Code:
    function ()
        local hp = UnitHealth("target")
        local hpMax = UnitHealthMax("target")
        local function fmt(num)
            local n = num
            local s = string.format("%.3f", n)
            for k,v in pairs {"", "K", "M", "B"} do
                n = num/math.pow(1000, k-1)
                if n < 1000 and n >= 1 then
                    s = string.format("%.f%s", n, v)
                end
            end
            return(s)
        end
        return (fmt(hp).."/"..fmt(hpMax))
    end
    First string.format controls numbers <1 (3 decimal digits), second string.format controls representation of our new string for >1 numbers (no decimals).
    You can control abbreviations (K, M, B, add more if you need) in array.

  11. #11
    Deleted
    Hi all!, have a slight problem, is there a chance to make weakaura show a spell crit? searched everywere and cant find something useful. example 2,000,000 "Lava Burst Icon" kinda hard to explain but hopefully you get what i mean, ty!

  12. #12
    These are the ones that are from the WA Discord. AbbreviateNumbers and AbbreviateLargeNumbers are both Blizzard functions and the wago.io links are player made. if using the wago.io ones you put them in Actions - OnInit and then call the function e.g aura_env.shortenNumber(value)

    AbbreviateNumbers(value) -- 1 decimal place
    AbbreviateLargeNumbers(value) Less abbreviated than above (1mil = 1,000k etc.)
    https://wago.io/shortenNumber -- 3 digits always
    https://wago.io/ShortenNumber -- custom decimal place

    - - - Updated - - -

    Quote Originally Posted by Kanegasi View Post
    Replace both instances of Health with Mana (case sensitive).
    UnitMana is removed btw, UnitPower(unit, 0) will be mana

  13. #13
    Quote Originally Posted by Rehok View Post
    UnitMana is removed btw, UnitPower(unit, 0) will be mana
    UnitMana was not removed, it was deprecated. There’s a difference. It is still in the game and still useable, but you are right that UnitPower should be used.

    Here is the code that enables UnitMana and UnitManaMax, located in Deprecated_7_2_0.lua:

    Code:
    do
    	-- Use UnitPower instead
    	function UnitMana(unit)
    		return UnitPower(unit, Enum.PowerType.Mana);
    	end
    
    	-- Use UnitPowerMax instead
    	function UnitManaMax(unit)
    		return UnitPowerMax(unit, Enum.PowerType.Mana);
    	end
    end

    Edit: my reply was also a year old
    Last edited by Kanegasi; 2018-01-12 at 06:24 PM.
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

Posting Permissions

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