1. Pitbull LUA question

    So I've just wasted the last few hours scouring the internet to find the LUA code so that I can color the text of my hunter pet based on its happiness using Pitbull. I used to have it as I stumbled across it somewhere but now I am unable to locate the information again. Is there a helpful person here who might be able to help work out the best way to do this?

    https://vanilla-wow.fandom.com/wiki/API_GetPetHappiness says that "GetPetHappiness()" is probably what I want to use, with the values of 1, 2, and 3 correlating to unhappy, content, and happy.

    Outline()
    local r,g,b = ClassColor(unit)
    return '|cff%02x%02x%02x%s%%',r,g,b,Percent(HP(unit),MaxH P(unit))
    This is the code that I use for my raid frame health text, and I'm hoping that my pet text will look the same, but colored based on happiness instead of class.

    Would be very appreciative of help from a knowledgeable person (I am not skilled in this area).

  2. Originally Posted by Chaoren2
    color the text of my hunter pet based on its happiness using Pitbull
    Try this:
    Code:
    Outline()
    if not GetPetHappiness() then
    	return
    end
    local petHappinessColors = {
    	[1] = {.69,.31,.31},
    	[2] = {.65,.63,.35},
    	[3] = {.33,.59,.33}
    }
    local r,g,b = unpack(petHappinessColors[GetPetHappiness()])
    return '|cff%02x%02x%02x%s',r*255,g*255,b*255,Name(unit)
    Quickly put together.
    Using oUF colors since there's no table for the color schemes.

    Couldn't test it since I don't have a hunter.

  3. It doesn't give me an error message, but it gives me the name of the unit colored by happiness instead of the health %.

  4. My bad, thought you wanted the name to be colored.

    Try this:

    Code:
    Outline()
    if not GetPetHappiness() then
    	return
    end
    local petHappinessColors = {
    	[1] = {.69,.31,.31},
    	[2] = {.65,.63,.35},
    	[3] = {.33,.59,.33}
    }
    local r,g,b = unpack(petHappinessColors[GetPetHappiness()])
    return '|cff%02x%02x%02x%s%%',r*255,g*255,b*255,Percent(HP(unit),MaxH P(unit))

  5. : / Gives error message too. Damn. Worked for the name but somehow not for health. For terms of economy, pitbull already has values for happiness color so I don't know if it's necessary to define them.

    What I had planned to do was leave the default setting for unhappy and content, but make the happy color match the hunter class color so my pet and I would have the same color text unless the pet needed to be fed. Used to look like this:




  6. For what it's worth, and since I am asking for help myself I thought I could share some other LUA scripts that I use for anyone looking to add some tweaks to their UI.

    To configure this in Pitull you go to the Layout Editor and pick the layout you want to modify and then go to the Text tab. Use the combo box to select the text you want to modify for that layout.

    I put an outline on all mine since I think it improves legibility, that's just "Outline()" before whatever code follows.


    Outline()
    local r,g,b = ClassColor(unit)
    return '|cff%02x%02x%02x%s%%',r,g,b,Percent(HP(unit),MaxH P(unit))
    This one displays health as a percentage in the unit's class color.


    Outline()
    local s = Status(unit)
    if s then
    return s
    end
    local cur, max = HP(unit), MaxHP(unit)
    local r,g,b=ClassColor(unit)
    return '|cff%02x%02x%02x%s/%s || %s%%|r',r,g,b,Short(cur,true),Short(max,true),Perc ent(cur,max)
    This one also puts health into class color but has the format of "25.5K/25.5k | 100%" instead of just percent.


    Outline()
    local abbr = Name(unit)
    local r,g,b = DifficultyColor(unit)
    if abbr:len() > 30 and abbr:find(" ")
    then abbr = abbr:gsub("([^ ]+) +", function(text)
    return text:sub(1,1) .. ". " end)
    end
    if UnitIsPlayer(unit) then
    local r,g,b = ClassColor(unit)
    return "|cff%02x%02x%02x%s|r",r,g,b,abbr
    else
    return "|cff%02x%02x%02x%s|r",r,g,b,abbr
    end
    This one will abbreviate the name if it is over 30 characters long (change the "30" to another value if you need to lengthen/shorten) and colors the unit name based on whether it's a player (in which case it is class colored) or if it's an NPC (in which it's colored by its difficulty level relative to you). Helpful for target frames since it won't try to assign a class to the the boss.


    Outline()
    return "|cffABD473%s|r",Name(unit)
    This one sets the name text to whatever color you specify in hex terms. The color part is the ABD473, which is the hunter class color.


    Outline()
    local r,g,b = ClassColor(unit)
    return '|cff%02x%02x%02x%s%%',r,g,b,VeryShort(HP(unit))
    This one is similar to an earlier code, but shows class colored health text in mini format (such as 41k). This is helpful on raid frames to quickly determine who the tank is.
    Edited: February 14, 2019

  7. Awesome, that seems to work just fine. Thank you very much!

Posting Permissions

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