Files
wow-weakauras/Complete Projects/Legion/Cross Char Quota.lua
2024-08-24 22:43:07 +02:00

66 lines
2.5 KiB
Lua

--PLAYER_ENTERING_WORLD BAG_UPDATE
function()
if UnitName("player") == "Pinkiepiie" then
CustomTrash.herbs = {}
local herbs = {"Starlight Rose", "Fjarnskaggl", "Foxflower", "Dreamleaf", "Aethril"}
for k,v in ipairs(herbs) do
CustomTrash.herbs[v] = GetItemCount(v, 1) --k berb v am
end
end
if UnitName("player") == "Kenono" then
aura_env.output = ""
local twok = 0
local currentherbs = {}
for k,v in pairs(CustomTrash.herbs) do
currentherbs[k] = v
end
for k,v in pairs(CustomTrash.herbs) do
currentherbs[k] = v + GetItemCount(k, 1)
if v >= 2400 then twok = twok + 1 end
end
local function hexgrad(val, min, max)
if val >= 2400 then return "|cff0000ff" end
local function tohex(input)
local output = string.format("%x", input * 255)
return output
end
local function grad(c, min, max)
c = 1 - (((max - c) / (max - min)) * 1)
if c > 0.5 then
c = 1 - (2 * (c - 0.5))
return c, 1, 0, 1
else
c = c * 2
return 1, c, 0, 1
end
end
local color1, color2, color3, color4 = 0, 0, 0, 0
color1, color2, color3, color4 = grad(val, min, max)
color1, color2, color3, color4 = tohex(color1), tohex(color2), tohex(color3), tohex(color4)
color1, color2, color3, color4 = tostring(color1), tostring(color2), tostring(color3), tostring(color4)
if string.len(color1) == 1 then color1 = "0" .. color1 end
if string.len(color2) == 1 then color2 = "0" .. color2 end
if string.len(color3) == 1 then color3 = "0" .. color3 end
if string.len(color4) == 1 then color4 = "0" .. color4 end
local color = "|c" .. color4 .. color1 .. color2 .. color3
return color
end
for k,v in pairs(currentherbs) do
if twok < 5 then
aura_env.output = aura_env.output .. hexgrad(v, 0, 2400) .. k .. " " .. v .. " / 2400" .. "|r" .. "\n"
end
end
end
end
--DISPLAY
function()
if UnitName("player") == "Kenono" then
return aura_env.output
else
return ""
end
end
--INIT
aura_env.output = ""