Originally Posted by Akatosh
I dont explain it well, The UI of the photo, dont be my UI.
Be just and example of the efect (of the colors) that I want for the durability bar.
|
I understand.
Originally Posted by Akatosh
Hi thanks for the help:
-------
No border.
No text.
No background (transparent or remove it).
I combine that with kgpanels for do that.
|
I see, in the lua file, delete / comment out any lines that have "statusbar.value" or "statusbar.bg"
-------
Texture of the bar, "Flat": (My_sharedmedia).
|
I don't know if the correct path is used for the texture in the script below, you may need to adjust the texture variable at the top of the file.
Color:
-Full durability: 0:86:15. (dark green).
-Mid durability: 205.205.0. (dark yellow).
-Little durability: 199:0:0. (dark red).
With the efect like the default config explain:
Little Dur-----betwen little/ mid-------Mid dur-------betwen mid/Full-----Full dur.
Dark red------mix of red/yelow-----Dark yellow-----mix of yellow/red----Dark red.
|
Below code should probably work. Open the lua file in notepad and paste the following in it.
I'll see if I can provide a kgPanels script
Code:
-- Adjust these
local texture = [[Interface\Addons\SharedMedia\statusbar\Flat]]
--local font = [[Fonts\FRIZQT__.TTF]]
local statusbar = CreateFrame("StatusBar", nil, UIParent)
-- Set the position top left, 100 px from top and left side
statusbar:SetPoint("TOPLEFT", 100, -100)
statusbar:SetWidth(150)
statusbar:SetHeight(25)
statusbar:SetStatusBarTexture(texture)
statusbar:GetStatusBarTexture():SetHorizTile(false) -- prevent weird looks
statusbar:GetStatusBarTexture():SetVertTile(false)
statusbar:SetStatusBarColor(0, 1, 0)
statusbar:SetMinMaxValues(0, 1) -- percentage.
statusbar:SetValue(1)
-- Statusbar background.
-- statusbar.bg = statusbar:CreateTexture(nil, "BACKGROUND")
-- statusbar.bg:SetTexture(texture)
-- statusbar.bg:SetAllPoints(true)
-- statusbar.bg:SetVertexColor(0, .5, 0)
-- statusbar.value = statusbar:CreateFontString(nil, "OVERLAY")
-- statusbar.value:SetPoint("CENTER")
-- statusbar.value:SetFont(font, 14, "OUTLINE")
-- statusbar.value:SetTextColor(1, 1, 1)
-- statusbar.value:SetText("100%")
-- statusbar.value:SetShadowOffset(0, 0)
-- statusbar.value:SetShadowColor(0, 0, 0, .2) -- just a little shadow to make the outline smooth
-- Credits goes to Tekkub!
local ids, slots = {}, {
"Head", "Shoulder", "Chest", "Legs", "Hands",
"Waist", "Feet", "Wrist",
"MainHand", "SecondaryHand",
}
for _, slot in pairs(slots) do
ids[(GetInventorySlotInfo(slot .. "Slot"))] = slot
end
slots = nil -- go away
local function PercentToRGB(perc, ...)
if perc >= 1 then
local r, g, b = select(select('#', ...) - 2, ...)
return r, g, b
elseif perc <= 0 then
local r, g, b = ...
return r, g, b
end
local num = select('#', ...) / 3
local segment, relperc = math.modf(perc*(num-1))
local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...)
return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc
end
--local coloredPercentFormat = '|cff%02x%02x%02x%.2f%%'
--local percentFormat = '%.2f%%'
statusbar:SetScript('OnEvent', function()
local percent, min, max, r, g, b = 1
for id, _ in pairs(ids) do
local min, max = GetInventoryItemDurability(id)
-- Only if item actually has durability (heirlooms anyone?)
if min and max and max > 0 then
-- set bar to inventory items lowest durability
-- because if one is at 10%, and the rest above 80%,
-- you need to repair anyway, right?
percent = math.min(min / max, percent)
end
end
-- Set the statusbar value
statusbar:SetValue(percent)
-- Get the color
-- set the calculated color
r, g, b = PercentToRGB(percent,
199 / 255, 0, 0, -- dark red
205 / 255, 205 / 255, 0, -- dark yellow
0, 86 / 255, 15 / 255 -- dark green
)
statusbar:SetStatusBarColor(r, g, b)
-- background 50% darker then front
--statusbar.bg:SetVertexColor(r / 2, g / 2, b / 2)
-- If you want the text to be colored, uncomment the following line.
--statusbar.value:SetFormattedText(coloredPercentFormat, r*255, g*255, b*255, percent*100)
--statusbar.value:SetFormattedText(percentFormat, percent * 100)
end)
statusbar:RegisterEvent('UPDATE_INVENTORY_DURABILITY')