Files
wow-weakauras/WeakAuras/Projects/Herb Quota.lua

64 lines
2.2 KiB
Lua

--PLAYER_ENTERING_WORLD BAG_UPDATE
function()
aura_env.output = ""
local herbs = {}
local twok = 0
for k, v in pairs(WeakAurasSaved.CustomTrash.HerbQuota) do
if UnitName("player") == "Pinkiepiie" then
WeakAurasSaved.CustomTrash.HerbQuota[k] = GetItemCount(k, 1)
else
herbs[k] = v + GetItemCount(k, 1)
end
if v >= 2400 then twok = twok + 1 end
end
local function hexgrad(val, min, max)
if val >= 2400 then return "\124cff3366ff" 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 = "\124c" .. color4 .. color1 .. color2 .. color3
return color
end
for k, v in pairs(WeakAurasSaved.CustomTrash.HerbQuota) do
if twok < 5 then
aura_env.output = aura_env.output .. hexgrad(v, 0, 2400) .. k .. " " .. v .. " / 2400" .. "\124r\n"
end
end
return true
end
--DISPLAY
function()
return aura_env.output
end
--INIT
aura_env.output = ""
if not WeakAurasSaved.CustomTrash.HerbQuota then WeakAurasSaved.CustomTrash.HerbQuota = {} end
WeakAurasSaved.CustomTrash.HerbQuota = {
["Starlight Rose"] = 0,
["Fjarnskaggl"] = 0,
["Foxflower"] = 0,
["Dreamleaf"] = 0,
["Aethril"] = 0,
}