Thread Tools Display Modes
07-27-13, 02:56 PM   #21
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by Fizzlemizz View Post
Essentially what I've given you is the variable called "text" that contains the information you want.
The following line needs to be replaced using whatever KgPanels does to update the display with the information from this "text" variable.

-- do whatever KgPanels uses to update the display with "text"

if
self.text:SetText(gold .. "g " .. silver .. "s " .. m - (10000*gold) - (100*silver) .. "c")
worked with your gold display then try:

self.text:SetText(text)
Thanks!!

For the text of gold I use that, and works fine, (atleast for me).

Onload

local font,size = self.text:GetFont()
self.text:SetFont(font,size,"OUTLINE")
self.text:SetJustifyH("CENTER")
self.text:SetJustifyV("CENTER")

local _, class = UnitClass("player")
local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
self.text:SetTextColor(color.r, color.g, color.b)
Onupdate

local m = GetMoney()
local gold = floor(m/10000)
local silver = floor((m - (10000*gold))/100)
local cooper = m - (10000*gold) - (100*silver)


self.text:SetText(string.format("Gold: |cffffffff%d|cffffcc00g |cffffffff%d|cffc0c0c0s |cffffffff%d|cff996600c",gold,silver,cooper))
For the --text Etc..I do not understand English very well so I do not understand what you mean by this ... leave me a little time to assimilate it.

Edit:

ok ok now understood!

local minutes, hour, minute
local t = date("*t", time())
hour = t.hour
minute = t.min
minutes = (hour*60) + minute
if (minutes > 1440) then
minutes = minutes - 1440
end
minutes = abs(minutes)
hour = floor(minutes/60)
minute = format("%02d", mod(minutes, 60))
local text
if minutes > 719 then
if minutes > 779 then
hour = floor(minutes/60) - 12
end
self.text:SetText(hour .. ":" .. minute .. " pm")
else
if (hour == 0) then
hour = 12
end
self.text:SetText(hour .. ":" .. minute .. " am")
end
With that, works fine, now I try to class color the text With White (hour) / classcolored (am/pm),wait a sencond and I put the code, I did it with some items I think I can do this too

Thanks!!

Edit2:

OnLoad

local font,size = self.text:GetFont()
self.text:SetFont(font,size,"OUTLINE")
self.text:SetJustifyH("CENTER")
self.text:SetJustifyV("CENTER")

local _, class = UnitClass("player")
local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
self.text:SetTextColor(color.r, color.g, color.b)
OnUpdate

.. self.text:SetText(string.format("|cffffffff%d:%d|r pm", hour,minute))
else
if (hour == 0) then
hour = 12
end
self.text:SetText(string.format("|cffffffff%d:%d|r am", hour,minute))
end..
itis curious but I have no zeros on left, example: 11:9pm Can you help me to fix that?

Thanks!!

Last edited by Akatosh : 07-27-13 at 03:19 PM.
  Reply With Quote
07-27-13, 03:13 PM   #22
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
If you are going to do it this way you can delete the line:

"local text"

as you are not using the variable named text in your script .
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
07-27-13, 03:27 PM   #23
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by Fizzlemizz View Post
If you are going to do it this way you can delete the line:

"local text"

as you are not using the variable named text in your script .
Ok I remove that line, Now I have a little problem... I have no zeros on left side of the tex, I edit my last post to explain it, you can help me to fix that?
  Reply With Quote
07-27-13, 04:09 PM   #24
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by Akatosh View Post
Ok I remove that line, Now I have a little problem... I have no zeros on left side of the tex, I edit my last post to explain it, you can help me to fix that?
I see the light man!!! I have no idea how can appear in my mind but works good now, I see the code of coords... And I say to me... Umm that be very similar, I put ".i" and nothing changed, ummm maybe if y put 2 appear 1 number more, and bammm.

The part of "OnLoad" be the some.

Now in OnUpdate:

local minutes, hour, minute
local t = date("*t", time())
hour = t.hour
minute = t.min
minutes = (hour*60) + minute
if (minutes > 1440) then
minutes = minutes - 1440
end
minutes = abs(minutes)
hour = floor(minutes/60)
minute = format("%02d", mod(minutes, 60))
if minutes > 719 then
if minutes > 779 then
hour = floor(minutes/60) - 12
end
self.text:SetText(string.format("|cffffffff%2i:%2i|r pm", hour,minute))
else
if (hour == 0) then
hour = 12
end
self.text:SetText(string.format("|cffffffff%2i:%.2i|r am", hour,minute))
end
Thanks for all, now I can zocus on the part of zone and subzone (with colors).

Last edited by Akatosh : 07-27-13 at 04:17 PM.
  Reply With Quote
07-30-13, 05:00 AM   #25
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
News!

I modify the codes that Phanx and Fizzlemizz provided to me (thanks), I explain, with one of the codes, the calendar works, but only when previously I loaded it manually the blizzard calendar with "/calendar", with the other code, when I click the panel, the frame of calendar only shows the time that I "mouse down" when I "mouse up", the frame disappear.

I try to modify the codes viewing codes of brokers and other lua relationated codes of calendar.

Finaly I got this:

if pressed and (not IsAddOnLoaded("Blizzard_Calendar")) then
UIParentLoadAddOn("Blizzard_Calendar")
Calendar_Show()
else
if pressed and (IsAddOnLoaded("Blizzard_Calendar")) then
Calendar_Toggle()
end
end
With that works now exactly how I want.

Thanks for all slowly, I am learning a lot and... I like!
  Reply With Quote
07-30-13, 12:23 PM   #26
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Exclamation

Hi!.

I have new questions!.

I want make a zonetext panels colored by pvp status.

I find information for other lua codes and for now I have this (Dont work of course Xddddd).

OnLoad

local font,size = self.text:GetFont()
self.text:SetFont(font,size,"OUTLINE")
self.text:SetJustifyH("CENTER")
self.text:SetJustifyV("CENTER")

self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PLAYER_FLAGS_CHANGED")
self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
self:RegisterEvent("PLAYER_LOGIN")
OnEvent
zone = GetRealZoneText()
subzone = GetSubZoneText()
self.text:SetText(string.format("%s, %s",zone,subzone))
Who I need:

1º:a class colored text based on pvp status, I extract that lua code, maybe can be usefull:

local pvpType, isFFA, faction = GetZonePVPInfo()
if(pvpType == "friendly") then
col = "00ff00"
elseif(pvpType == "hostile") then
col = "ff0000"
elseif(pvpType == "arena") then
col = "ffff00"
elseif(pvpType == "hostile" or pvpType == "combat" or pvpType=="contested") then
if(faction == select(2,UnitFactionGroup('player'))) then
col = "886600"
else
col = "ff0000"
end
elseif(pvpType == "sanctuary") then
col = "9999ff"
else
return txt
end
return addon['colorize'](txt, col)
But I dont have idea how can I apply to text.

2º: When I enter in a zone with no subzone appear only the Main zone, for example, I enter on Dalaran, appear "Dalaran, Dalaran", When the correct be that only appear 1 dalaran: "Dalaran".

Any help will be greatly appreciated Thanks!!!

Last edited by Akatosh : 07-30-13 at 12:33 PM.
  Reply With Quote
07-30-13, 01:17 PM   #27
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
If you weant sub-zone information you will also need to register "ZONE_CHANGED".

The "ZONE_CHANGED_NEW_AREA" event fires whe you cross zone borders and "ZONE_CHANGED" when you cross unto a new sub-zone. You might also want to register "ZONE_CHANGED_INDOORS" which is trggered when you go from inside to out or outside to in.

You can find the list of zone related functions at WowProgramming.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
07-30-13, 01:49 PM   #28
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by Fizzlemizz View Post
If you weant sub-zone information you will also need to register "ZONE_CHANGED".

The "ZONE_CHANGED_NEW_AREA" event fires whe you cross zone borders and "ZONE_CHANGED" when you cross unto a new sub-zone. You might also want to register "ZONE_CHANGED_INDOORS" which is trggered when you go from inside to out or outside to in.

You can find the list of zone related functions at WowProgramming.
Thanks for the tip!!.

I added to "Onload" section.

If you can help me with colored text....

¿how can I do for do a text colored zonetext based on pvp status?.

I have this base code maybe can help:

local pvpType, isFFA, faction = GetZonePVPInfo()
if(pvpType == "friendly") then
col = "00ff00"
elseif(pvpType == "hostile") then
col = "ff0000"
elseif(pvpType == "arena") then
col = "ffff00"
elseif(pvpType == "hostile" or pvpType == "combat" or pvpType=="contested") then
if(faction == select(2,UnitFactionGroup('player'))) then
col = "886600"
else
col = "ff0000"
end
elseif(pvpType == "sanctuary") then
col = "9999ff"
I need help on the second point to:

2º: When I enter in a zone with no subzone appear only the Main zone, for example, I enter on Dalaran, appear "Dalaran, Dalaran", When the correct be that only appear 1 dalaran: "Dalaran".

A lot of Thanks Fizzlemizz.
  Reply With Quote
07-30-13, 02:41 PM   #29
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
The code appears to be only part of a function for getting the appropriate colour. It also seems to asume the the alpha chanel will be set elsewhere but I'll change to set it here
Code:
local col
local pvpType, isFFA, faction = GetZonePVPInfo()
if(pvpType == "friendly") then
	col = "ff00ff00" -- friendly colour
elseif(pvpType == "hostile") then
	col = "ffff0000" -- hostile colour
elseif(pvpType == "arena") then
	col = "ffffff00"  -- arena colour
elseif(pvpType == "hostile" or pvpType == "combat" or pvpType=="contested") then
	if(faction == select(2,UnitFactionGroup('player'))) then
		col = "ff886600" -- faction colour for player
	else
		col = "ffff0000" -- other faction colour colour for player
	end
elseif(pvpType == "sanctuary") then
	col = "ff9999ff"  -- sanctuary colour
end
As for changing zones something like:
Code:
local zone, subzone
if event == "ZONE_CHANGED_NEW_AREA" then
	zone = GetRealZoneText()
        self:text:SetText(zone)
elseif event == "ZONE_CHANGED" then
        zone = GetRealZoneText()
	subzone = GetSubZoneText()
	if subzone == "" then
		self:text:SetText(zone)
	else
		self:text:SetText(subzone)
	end
end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 07-30-13 at 02:45 PM.
  Reply With Quote
07-30-13, 02:41 PM   #30
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 223
Is the following what you are looking for?

For the multi-zone feature you should note that ALL GetZone functions return the Zone if there is no Sub-Zone. The colors are a tad tricky but if those are the accepted values then that works.
If you're more comfortable with one single object then replace the 'return string.format' with 'self.text:SetFormattedText'.
Code:
local pvpType, _, faction = GetZonePVPInfo()
local col
if(pvpType == "friendly") then
     col = "00ff00"
elseif(pvpType == "hostile") then
     col = "ff0000"
elseif(pvpType == "arena") then
     col = "ffff00"
elseif(pvpType == "combat" or pvpType=="contested") then
     if(faction == select(2,UnitFactionGroup('player'))) then
          col = "886600"
     else
          col = "ff0000"
     end
elseif(pvpType == "sanctuary") then
     col = "9999ff"
else
     col = "00ff00"
end
local zone, sub = GetZoneText(), GetSubZoneText()
if sub == zone then
     return string.format("|cff%s%s|r", col, zone)
else
     return string.format("|cff%s%s, %s|r", col, zone, sub)
end
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

Last edited by jeruku : 07-30-13 at 02:44 PM. Reason: Typo
  Reply With Quote
07-30-13, 03:01 PM   #31
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
I was just about to post something similar. I changed the returns because Akatosh is using this in a KgPanels script not as a standalone function. Also changed a bit because sub can be blank.

Code:
if sub == "" then
     self.text:SetText(string.format("|cff%s%s|r", col, zone))
else
     self.text:SetText(string.format("|cff%s%s|r", col, sub))
end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 07-30-13 at 03:27 PM.
  Reply With Quote
07-30-13, 03:16 PM   #32
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by jeruku View Post
Is the following what you are looking for?

For the multi-zone feature you should note that ALL GetZone functions return the Zone if there is no Sub-Zone. The colors are a tad tricky but if those are the accepted values then that works.
If you're more comfortable with one single object then replace the 'return string.format' with 'self.text:SetFormattedText'.
Code:
local pvpType, _, faction = GetZonePVPInfo()
local col
if(pvpType == "friendly") then
     col = "00ff00"
elseif(pvpType == "hostile") then
     col = "ff0000"
elseif(pvpType == "arena") then
     col = "ffff00"
elseif(pvpType == "combat" or pvpType=="contested") then
     if(faction == select(2,UnitFactionGroup('player'))) then
          col = "886600"
     else
          col = "ff0000"
     end
elseif(pvpType == "sanctuary") then
     col = "9999ff"
else
     col = "00ff00"
end
local zone, sub = GetZoneText(), GetSubZoneText()
if sub == zone then
     return string.format("|cff%s%s|r", col, zone)
else
     return string.format("|cff%s%s, %s|r", col, zone, sub)
end
Originally Posted by Fizzlemizz View Post
I was just about to post something similar but I think most common use would be

Code:
if sub == zone then
     self.text:SetText(string.format("|cff%s%s|r", col, zone))
else
     self.text:SetText(string.format("|cff%s%s|r", col, sub))
end
I also changed the returns because Akatosh is using this in a KgPanels script not as a standalone function.

Hi all a lot of thanks!!!!, I am very happy.

It works... not exactly one of other... a mix of the two:

local pvpType, _, faction = GetZonePVPInfo()
local col
if(pvpType == "friendly") then
col = "00ff00"
elseif(pvpType == "hostile") then
col = "ff0000"
elseif(pvpType == "arena") then
col = "ffff00"
elseif(pvpType == "combat" or pvpType=="contested") then
if(faction == select(2,UnitFactionGroup('player'))) then
col = "886600"
else
col = "ff0000"
end
elseif(pvpType == "sanctuary") then
col = "9999ff"
else
col = "00ff00"
end
local zone, sub = GetZoneText(), GetSubZoneText()
if sub == zone then
self.text:SetText(string.format("|cff%s%s|r", col, zone))
else
self.text:SetText(string.format("|cff%s%s, %s|r", col, zone, sub))
end
120kbs less of memory usage (1 addon) for 25 lines.

I put OnClick:
ToggleFrame(WorldMapFrame)
Now that panel is complete!!, ever is less, to finish the interface with your help.

Last edited by Akatosh : 07-30-13 at 03:31 PM.
  Reply With Quote
07-30-13, 06:24 PM   #33
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 223
Originally Posted by Fizzlemizz View Post
I was just about to post something similar. I changed the returns because Akatosh is using this in a KgPanels script not as a standalone function. Also changed a bit because sub can be blank.

Code:
if sub == "" then
     self.text:SetText(string.format("|cff%s%s|r", col, zone))
else
     self.text:SetText(string.format("|cff%s%s|r", col, sub))
end

That is why I mentioned SetFormattedText(). It does the SetText() as if it were string.format().

Thanks for correcting me Fizz, GetSubZoneText() does indeed return an empty string.

I also have a tip on appearance, one could move the color escape '|r' and nestle it between the two zones; this would result in only the major zone being colored. Here's an example with a correction of my code with Fizz's fix.

Stormwind, Dwarven District
Code:
if sub == "" then
     self.text:SetFormattedText("|cff%s%s|r", col, zone)
else
     self.text:SetFormattedText("|cff%s%s|r, %s", col, zone, sub)
end
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

Last edited by jeruku : 07-30-13 at 06:24 PM. Reason: Somehow forgot the quote?
  Reply With Quote
08-05-13, 10:41 AM   #34
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Thumbs up

Hello again!, again I have questions!.

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:

--[[
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)
What I understand.

The first part appear something like a register of class and their buff, the second part appear a count of the buffs, the third be the tooltip, And finally the number of current buffs and total buffs.

He looks like that with the broker

¿¿You can make it work for kgpanels??

A lot of thanks!!

PD: whats the diference betwen "{ or }" and "( or )"

Last edited by Akatosh : 08-05-13 at 03:13 PM.
  Reply With Quote
08-05-13, 05:25 PM   #35
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Please use [code] tags around code blocks, not [quote] tags -- the latter does not preserve indentation, and makes the code annoyingly difficult to read.

Originally Posted by Akatosh View Post
PD: whats the diference betwen "{ or }" and "( or )"
{ curly brackets } create a table object:

Code:
-- Indexed table, array, or list:
local animals = { "cat", "dog", "pig" }

-- Dictionary table, or hash table:
local animals = {
   ["cat"] = "meow",
   ["dog"] = "woof",
   ["pig"] = "oink",
}
( parenthesis ) enclose conditions or function arguments:

Code:
-- This:
if thisVar == 5 or (thatVar == 2 and otherVar == "x") then
   -- do something
end

-- ... is a more compact way of writing this:
if thisVar == 5 then
   -- do something
elseif thatVar == 2 and otherVar == "x" then
   -- do the same thing
end
Code:
function DoSomething(thisVar, thatVar, otherVar)
   -- do something
end

DoSomething(5, 2, "x")
However, I really feel like a broken record here, but copying all these Broker plugins and shoehorning them into kgPanels is really pointless. The Broker plugin you posted won't take up any more memory than a kgPanels panel running the same code (in fact, it will probably take up less memory) and a Broker display addon is not any more heavyweight than kgPanels -- but on any machine capable of running WoW at all, worring about a few dozen or even a few hundred KB is just laughably irrelevant. You might as well worry that one of your T-shirts has 15 more molecules than another, and that those few extra molecules are going to somehow be the difference between you being able to walk around normally, and you being collapsed into a black hole. That memory really does not matter one bit.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 08-05-13 at 05:30 PM.
  Reply With Quote
08-05-13, 06:13 PM   #36
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
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.
  Reply With Quote
08-05-13, 06:26 PM   #37
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Akatosh View Post
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!!!
It's possible, yes, but while I'm willing to help out with simple scripting like "click to show something" or "change color based on class", a raid buff monitor is pretty far outside the realm of what I think kgPanels is designed to do, and there's no way I'm spending my free time rewriting other people's perfectly functional (and likely copyrighted) Broker plugins into complicated kgPanels scripts for you, sorry.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-05-13, 07:12 PM   #38
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by Phanx View Post
It's possible, yes, but while I'm willing to help out with simple scripting like "click to show something" or "change color based on class", a raid buff monitor is pretty far outside the realm of what I think kgPanels is designed to do, and there's no way I'm spending my free time rewriting other people's perfectly functional (and likely copyrighted) Broker plugins into complicated kgPanels scripts for you, sorry.
I did not force you to help me, you are free to do it, or not, for other side I dont copy their broker, I just take their code as a reference to adapt it to kgpanels.

Even for me, I do not know almost nothing, I understand that is something completely different.

Last edited by Akatosh : 08-05-13 at 07:16 PM.
  Reply With Quote
08-05-13, 08:57 PM   #39
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Hi Akatosh,

I see from the RaidBuffStatus page here at WowInterface that it is out of date and from the comments not working. I also see from the DL at Curse that the code, as Phanx pounted out, is most likely copyrighted and now uses 13 libraries and the core.lua file is nearly 5,000 lines long.

I'm sorry to say that in this case while it may be technically possible to do, it would not be quick or easy (even if someone had a clue where to start) and most likely is not worth the time.

Sorry.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-05-13, 09:54 PM   #40
Akatosh
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jun 2013
Posts: 84
Originally Posted by Fizzlemizz View Post
Hi Akatosh,

I see from the RaidBuffStatus page here at WowInterface that it is out of date and from the comments not working. I also see from the DL at Curse that the code, as Phanx pounted out, is most likely copyrighted and now uses 13 libraries and the core.lua file is nearly 5,000 lines long.

I'm sorry to say that in this case while it may be technically possible to do, it would not be quick or easy (even if someone had a clue where to start) and most likely is not worth the time.

Sorry.
Thanks for the reply, I have a bit issue with that.

http://www.wowinterface.com/forums/s...52&postcount=5

Works ok but, only for 1 time (1 mouseover), If I mouseover 2 times the text come one more time to original color. ¿You kwon how can I fix that?.

Thanks!!.

For the other side I countinue trying the part of the raidbuffs, I think that with time maybe can I do it, I refuse to give up so fast, there must be some way to do it.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Helps with Kgpanels!


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off