I see the broker "RaidBuffs", and explore the code.
Dont apperar a lot of dificult... I understand it a bit.
The problem be that, I dont have idea, How can I adap It, to a panel for kgpanels, I think that be posible do it.
See if you can make it work!!!
The code:
Code:
local ldb = LibStub("LibDataBroker-1.1")
--[[
local localizedClasses = {}
FillLocalizedClassList(localizedClasses)
local classLabels = {}
populateClassLabels("HUNTER")
populateClassLabels("WARRIOR")
populateClassLabels("PALADIN")
populateClassLabels("MAGE")
populateClassLabels("PRIEST")
populateClassLabels("WARLOCK")
populateClassLabels("SHAMAN")
populateClassLabels("DEATHKNIGHT")
populateClassLabels("DRUID")
populateClassLabels("MONK")
populateClassLabels("ROGUE")
local populateClassLabels(class)
classLabels[class] = {localizedClasses[class], RAID_CLASS_COLORS[class]}
print(classLabels[class][1], classLabels[class][2], classLabels[class][3], classLabels[class][4])
end
--]]
-- displayName, active, {buff = {class [, note]}, ...}
local buffsList = {
{"5% stats", false, {
[20217] = {"PALADIN"}, -- Blessing of Kings
[117666] = {"MONK"}, -- Legacy of the Emporer
[1126] = {"DRUID"}, -- Mark of the Wild
[90363] = {"HUNTER", "Exotic Pet"}, -- Embrace of the Shale Spider
[133539] = {"Krasang Wilds Druid"}, -- Dominion Point/Lion's Landing NPCs
}},
{"Attack Power", false, {
[19506] = {"HUNTER"}, -- Trueshot Aura
[6673] = {"WARRIOR"}, -- Battle Shout
[57330] = {"DEATHKNIGHT"}, -- Horn of Winter
[133540] = {"Krasang Wilds Warrior"}, -- Dominion Point/Lion's Landing NPCs
}},
{"Attack Speed", false, {
[113742] = {"ROGUE"}, -- Swiftblade's Cunning
[55610] = {"DEATHKNIGHT", "Frost & Unholy"}, -- Unholy Aura
[30809] = {"SHAMAN", "Enhancement"}, -- Unleashed Rage
[128432] = {"HUNTER", "Pet"}, -- Cackling Howl
[128433] = {"HUNTER", "Pet"}, -- Serpent's Swiftness
[133541] = {"Krasang Wilds Rogue"}, -- Dominion Point/Lion's Landing NPCs
}},
{"Spell Power", false, {
[1459] = {"MAGE"}, -- Arcane Brilliance
[61316] = {"MAGE"}, -- Dalaran Brilliance
[77747] = {"SHAMAN"}, -- Burning Wrath
[109773] = {"WARLOCK"}, -- Dark Intent
[126309] = {"HUNTER", "Exotic Pet"}, -- Still Water
[133533] = {"Krasang Wilds Mage"}, -- Dominion Point/Lion's Landing NPCs
}},
{"Spell Haste", false, {
[24907] = {"DRUID", "Balance"}, -- Moonkin Aura
[24858] = {nil}, -- Druid's Moonkin Aura Self Buff
[49868] = {"PRIEST", "Shadow"}, -- Mind Quickening
[15473] = {nil}, -- Priest's Mind Quickening Self Buff
[51470] = {"SHAMAN", "Elemental"}, -- Elemental Oath
[135678] = {"HUNTER", "Pet"}, -- Energizing Spores
[133545] = {"Krasang Wilds Shaman"}, -- Dominion Point/Lion's Landing NPCs
}},
{"Mastery", false, {
[19740] = {"PALADIN"}, -- Blessing of Might
[116956] = {"SHAMAN"}, -- Grace of Air
[93435] = {"HUNTER", "Pet"}, -- Roar of Courage
[128997] = {"HUNTER", "Exotic Pet"}, -- Spirit Beast Blessing
[133535] = {"Krasang Wilds Paladin"}, -- Dominion Point/Lion's Landing NPCs
}},
{"Crit Chance", false, {
[1459] = {"MAGE"}, -- Arcane Brilliance
[61316] = {"MAGE"}, -- Dalaran Brilliance
[17007] = {"DRUID", "Feral & Guardian"}, -- Leader of the Pack
[116781] = {"MONK", "Windwalker"}, -- Legacy of the White
[126373] = {"HUNTER", "Exotic Pet"}, -- Fearless Courage
[24604] = {"HUNTER", "Pet"}, -- Furious Howl
[126309] = {"HUNTER", "Exotic Pet"}, -- Still Water
[90309] = {"HUNTER", "Exotic Pet"}, -- Terrifying Roar
[133533] = {"Krasang Wilds Mage"}, -- Dominion Point/Lion's Landing NPCs
}},
{"Stamina", false, {
[21562] = {"PRIEST"}, -- Power Word: Fortitude
[469] = {"WARRIOR"}, -- Commanding Shout
[109773] = {"WARLOCK"}, -- Dark Intent
[90364] = {"HUNTER", "Exotic Pet"}, -- Qiraji Fortitude
[133538] = {"Krasang Wilds Priest"}, -- Dominion Point/Lion's Landing NPCs
}},
}
local BrokerRaidBuffs = ldb:NewDataObject("Broker_RaidBuffs", {
type = "data source",
text = "Please wait",
value = 1,
icon = "interface\\addons\\Broker_RaidBuffs\\BuffConsolidation",
label = "RaidBuffs",
OnTooltipShow = function(tooltip)
tooltip:AddLine("Raidbuffs")
for _,v in pairs(buffsList) do
local r, g, b
if v[2] then
r, g, b = 0, 1, 0
else
r, g, b = 1, 0, 0
end
tooltip:AddLine(v[1], r, g, b)
end
end
})
local function updateBuffs(self, event, unitID)
if (unitID == "player" or event == "PLAYER_ENTERING_WORLD") then
-- unflag the active buffs
for i=1, #buffsList do
buffsList[i][2] = false
end
-- populate our buffs lookup table
local activeBuffs, i = {}, 1
local currentBuff = select(11, UnitBuff("player", i))
while currentBuff do
activeBuffs[currentBuff] = true
i = i + 1
currentBuff = select(11, UnitBuff("player", i))
end
local activeRaidBuffs = 0
-- start the lookup
for i = 1, #buffsList do
local raidBuff = buffsList[i][3]
for key, _ in pairs(raidBuff) do
if activeBuffs[key] then
buffsList[i][2] = true
activeRaidBuffs = activeRaidBuffs + 1
break
end
end
end
BrokerRaidBuffs.text = activeRaidBuffs .. " / 8"
end
end
local EventFrame = CreateFrame("Frame")
EventFrame:RegisterEvent("UNIT_AURA")
EventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
EventFrame:SetScript("OnEvent", updateBuffs)
Better?.
Thanks for the tips, Phanx, I dont want sound rude or border, I'm very grateful to the help that you have rendered me, I respect your point of view, but please be reciprocal with the mine, can be do it by two ways, Kgpanels or broker (or more, I think), is a matter of choice in my opinion.
I wish I could do it myself, but I can not learn faster than my personal life allows me to learn, sorry if I'm asking too much, but I have no alternative, because I do not understand how to do this.