WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   PitBull4 Lua texts - Colored health and power? (https://www.wowinterface.com/forums/showthread.php?t=40547)

slayos 03-10-16 12:16 PM

Quote:

Originally Posted by Fizzlemizz (Post 313527)
local perc = Percent(cur,max)

Would appear to be converting current health into a percentage of max so if you just change perc to cur as the return by:
Code:

        if perc >= 76 then
                return "|cff00d036%s%%|r", cur
        elseif perc >= 26 then
                return "|cfff19c08%s%%|r",cur
        else
                return "|cfff10808%s%%|r",cur
        end

You also have duplicate
Code:

local s = Status(unit)
if s then
    return s
end

Statements.
For the boss you woulld need to substitute the function it's using to convert the values and replace it with Percent as in your code above.

Could you possible give me my code back fixed the way that you'd do it? I'm not really that good at coding.

Fizzlemizz 03-10-16 12:18 PM

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
if UnitIsFriend(unit,"player") then
        if perc >= 76 then
                return "|cff00d036%s%%|r", cur
        elseif perc >= 26 then
                return "|cfff19c08%s%%|r",cur
        else
                return "|cfff10808%s%%|r",cur
        end
else
        return perc
end


slayos 03-10-16 12:23 PM

Quote:

Originally Posted by Fizzlemizz (Post 313529)
Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
if UnitIsFriend(unit,"player") then
        if perc >= 76 then
                return "|cff00d036%s%%|r", cur
        elseif perc >= 26 then
                return "|cfff19c08%s%%|r",cur
        else
                return "|cfff10808%s%%|r",cur
        end
else
        return perc
end


an issue has accured, on target "friendly" it shows their name exactly as i want it however with a % behind it, so let's say i got 418500 health it displays like this 418500% and on unfriendly target it displays like i want ut however 100 instred of 100%

Fizzlemizz 03-10-16 12:37 PM

Apologies, too early in the morning ;).

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
if UnitIsFriend(unit,"player") then
        if perc >= 76 then
                return "|cff00d036%s|r",cur
        elseif perc >= 26 then
                return "|cfff19c08%s|r",cur
        else
                return "|cfff10808%s|r",cur
        end
else
        return "%s%%",perc
end


slayos 03-10-16 12:39 PM

Quote:

Originally Posted by Fizzlemizz (Post 313531)
Apologies, too early in the morning ;).

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
if UnitIsFriend(unit,"player") then
        if perc >= 76 then
                return "|cff00d036%s|r", cur
        elseif perc >= 26 then
                return "|cfff19c08%s|r",cur
        else
                return "|cfff10808%s|r",cur
        end
else
        return "%s%%",perc
end


NICE! you have no idea how long i've been working on getting this fixed!!!, if it's not to much to ask since you're so good at this xD is it possible to make the unfriendly text colored like the friendly one to? i am a perfectionist xD

Fizzlemizz 03-10-16 12:44 PM

Something like:

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
local ret
if perc >= 76 then
        ret = "|cff00d036%s"
elseif perc >= 26 then
        ret = "|cfff19c08%s"
else
        ret = "|cfff10808%s"
end
if UnitIsFriend(unit,"player") then
        ret = ret.."|r"
        return ret,cur
else
        ret = ret.."%%"|r"
        return ret,perc
end


slayos 03-10-16 12:46 PM

Quote:

Originally Posted by Fizzlemizz (Post 313533)
Something like:

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
local ret
if perc >= 76 then
        ret = "|cff00d036%s"
elseif perc >= 26 then
        ret = "|cfff19c08%s"
else
        ret = "|cfff10808%s"
end
if UnitIsFriend(unit,"player") then
        ret = ret.."|r"
        return ret,cur
else
        ret = ret.."%%"|r"
        return ret,perc
end


Doesn't work :P

Fizzlemizz 03-10-16 12:50 PM

Way too early ..

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
local ret
if perc >= 76 then
        ret = "|cff00d036%s"
elseif perc >= 26 then
        ret = "|cfff19c08%s"
else
        ret = "|cfff10808%s"
end
if UnitIsFriend(unit,"player") then
        ret = ret.."|r"
        return ret,cur
else
        ret = ret.."%%|r"
        return ret,perc
end


slayos 03-10-16 12:53 PM

Quote:

Originally Posted by Fizzlemizz (Post 313535)
Way too early ..

Code:

local s = Status(unit)
if s then
        return s
end
local cur, max = HP(unit), MaxHP(unit)
local perc = Percent(cur,max)
local ret
if perc >= 76 then
        ret = "|cff00d036%s"
elseif perc >= 26 then
        ret = "|cfff19c08%s"
else
        ret = "|cfff10808%s"
end
if UnitIsFriend(unit,"player") then
        ret = ret.."|r"
        return ret,cur
else
        ret = ret.."%%|r"
        return ret,perc
end


worked xD thank you, i wish i was as good in coding, would've made this so much easyer lol xD

want to do 1 last before i got my whole ui complete? this one shouldn't be complicated :)
Quote:

local _,power_name = UnitPowerType(unit)
local r,g,b = PowerColor(power_name)
local max = MaxPower(unit)
if max > 0 then
return "|cff%02x%02x%02x%s | %s",r,g,b,Short(Power(unit),true),Short(max,true)
end
this code is showing the text code like this "32.0k | 32.0k" but I want it to display it like this "32000"

Fizzlemizz 03-10-16 01:09 PM

local _,power_name = UnitPowerType(unit)
local r,g,b = PowerColor(power_name)
local max = MaxPower(unit)
if max > 0 then
return "|cff%02x%02x%02x%s|r",r,g,b,Power(unit)
end

slayos 03-10-16 01:13 PM

Quote:

Originally Posted by Fizzlemizz (Post 313537)
local _,power_name = UnitPowerType(unit)
local r,g,b = PowerColor(power_name)
local max = MaxPower(unit)
if max > 0 then
return "|cff%02x%02x%02x%s|r",r,g,b,Power(unit)
end

i think that's it ;O thank you so much for the assistance m8, if i can do anything for you!

ceylina 03-11-16 12:30 PM

Not sure if you want it at all but here is my coding for health and power bars

I only color the health or power percentage and not the current/max health amount.

Health:

Code:

local cur, max = HP(unit), MaxHP(unit)
local r,g,b = HPColor(cur,max)
return "%s/%s |cff%02x%02x%02x(%s%%)|r",Short(cur,true),Short(max,true),r,g,b,Percent(cur,max)


Power:

Code:

local cur,max = Power(unit),MaxPower(unit)
local _,power_name = UnitPowerType(unit)
local r,g,b = PowerColor(power_name)
  return "%s/%s |cff%02x%02x%02x(%s%%)|r",Short(cur,true),Short(max,true),r,g,b,Percent(cur,max)


Druid mana

Code:

if UnitPowerType(unit) ~= 0 and DruidForm(unit) then
  local max = MaxPower(unit,0)
  local color = PitBull4.PowerColors["MANA"]
  local r,g,b = color[1]*255, color[2]*255, color[3]*255
    return "|cff%02x%02x%02x(%s%%)|r",r,g,b,Percent(Power(unit,0),max)
end


slayos 03-15-16 09:04 PM

Druid Mana
 
how can i get this code
Quote:

if UnitPowerType(unit) ~= 0 and DruidForm(unit) then
local max = MaxPower(unit,0)
local color = PitBull4.PowerColors["MANA"]
local r,g,b = color[1]*255, color[2]*255, color[3]*255
return "|cff%02x%02x%02x(%s%%)|r",r,g,b,Percent(Power(unit,0),max)
end
to show Cur insted of Percent?

like so "32000" if that's whatt my mana is? :)

Thanks in advanse

Fizzlemizz 03-15-16 09:08 PM

Code:

if UnitPowerType(unit) ~= 0 and DruidForm(unit) then
        local color = PitBull4.PowerColors["MANA"]
        local r,g,b = color[1]*255, color[2]*255, color[3]*255
        return "|cff%02x%02x%02x(%s)|r",r,g,b,Power(unit,0)
end


slayos 03-15-16 09:11 PM

Thanks
 
Quote:

Originally Posted by Fizzlemizz (Post 313623)
Code:

if UnitPowerType(unit) ~= 0 and DruidForm(unit) then
        local color = PitBull4.PowerColors["MANA"]
        local r,g,b = color[1]*255, color[2]*255, color[3]*255
        return "|cff%02x%02x%02x(%s)|r",r,g,b,Power(unit,0)
end


heh it's you again, seems like my UI just refuse to be done, there seem to duck up problems, after problems are solved heh ^ glad i got you to back me up though!

slayos 03-15-16 09:30 PM

You don't happen to know a code that displays the spec of the player?

let's say i meet a "Holy Paladin" i got a own code that says f.ex "Holy" with class colored text or eventually show a img of the spec? pref the img is possible but text is more than fine!

Fizzlemizz 03-16-16 09:59 AM

I don't know Pitbull well enough to tell you exactly how but the process of getting a specialisation comes in two parts.

First determine if the target can be inspected and if so send an inspect request to the server.
Code:

if CanInspect("target") then
        frame:RegisterEvent("INSPECT_READY")
        NotifyInspect("target")
else
        print("Can't inspect target")
end

Once the server has gathered the information it will send an "INSPECT_READY" event to the designated frame(s) which can then retrieve the information.

Frames OnEvent script for the "INSPECT_READY" event:
Code:

local spec_id = GetInspectSpecialization("target")
self:UnregisterEvent("INSPECT_READY")
ClearInspectPlayer()
local id, name, description, icon, background, role, class = GetSpecializationInfoByID(spec_id)
print(name) -- or set a texture to display the icon


slayos 03-16-16 10:18 AM

How do i perform this action?


All times are GMT -6. The time now is 11:29 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI