Thread Tools Display Modes
01-12-13, 08:36 AM   #1
liquidbase
A Warpwood Thunder Caller
 
liquidbase's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 97
Problem with a buffnotice-script

Sers

I got a problem with a buffnotice-script which I use in DuffedUI.
The script makes use of a defined table with skills that outputs depending on the class, if a selfbuff is missing (like Horn of Winter from a DK). The script itself works, but always a black box appears when you learn skills through a level increase. This changes only if the first skill has been learned from table or I reload the UI.

If anyone has any idea how I work around the problem of the black box, just tell me so can
Thanks in advance for any help.

Greetz
liquidbase

Screenshot:


Script:
Code:
local D, C, L, G = unpack(select(2, ...))
if C["auras"].buffnotice ~= true then return end

-- Nasty stuff below. Don't touch.
local buffs = D.remindbuffs[D.myclass]

if not buffs then return end

local sound
local function BuffsOnEvent(self, event)
	if (event == "PLAYER_LOGIN" or event == "LEARNED_SPELL_IN_TAB") then
		for i, buff in pairs(buffs) do
			local name = GetSpellInfo(buff)
			local usable, nomana = IsUsableSpell(name)
			if (usable or nomana) then
				self.icon:SetTexture(select(3, GetSpellInfo(buff)))
				break
			end
		end
		if (not self.icon:GetTexture() and event == "PLAYER_LOGIN") then
			self:UnregisterAllEvents()
			self:RegisterEvent("LEARNED_SPELL_IN_TAB")
			return
		elseif (self.icon:GetTexture() and event == "LEARNED_SPELL_IN_TAB") then
			self:UnregisterAllEvents()
			self:RegisterEvent("UNIT_AURA")
			self:RegisterEvent("PLAYER_LOGIN")
			self:RegisterEvent("PLAYER_REGEN_ENABLED")
			self:RegisterEvent("PLAYER_REGEN_DISABLED")
		end
	end

	if (UnitAffectingCombat("player") and not UnitInVehicle("player")) then
		for i, buff in pairs(buffs) do
			local name = GetSpellInfo(buff)
			if (name and UnitBuff("player", name)) then
				self:Hide()
				sound = true
				return
			end
		end
		self:Show()
		if sound == true then
			if C["auras"].warning then
				PlaySoundFile(C["media"].warning)
			end
			sound = false
		end
	else
		self:Hide()
		sound = true
	end
end

local frame = CreateFrame("Frame", "DuffedUIBuffsWarningFrame", UIParent)
frame.icon = frame:CreateTexture(nil, "OVERLAY")
frame.icon:SetPoint("CENTER")
frame:SetTemplate("Default")
frame:Size(40)
frame:Point("CENTER", UIParent, "CENTER", -30, 100)
frame.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
frame.icon:Size(36)
frame:Hide()

frame:RegisterEvent("UNIT_AURA")
frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
frame:RegisterEvent("PLAYER_REGEN_DISABLED")
frame:RegisterEvent("UNIT_ENTERING_VEHICLE")
frame:RegisterEvent("UNIT_ENTERED_VEHICLE")
frame:RegisterEvent("UNIT_EXITING_VEHICLE")
frame:RegisterEvent("UNIT_EXITED_VEHICLE")

frame:SetScript("OnEvent", BuffsOnEvent)
Table:
Code:
D.remindbuffs = {
	PRIEST = {
		588, -- Inner Fire
		73413, -- Inner Will
	},
	HUNTER = {
		13165, -- Aspect of the Hawk
		5118, -- Aspect of the Cheetah
		13159, -- Aspect of the Pack
		82661, -- Aspect of the Fox
		109260, -- Aspect of the Iron Hawk
	},
	MAGE = {
		7302, -- Frost Armor
		6117, -- Mage Armor
		30482, -- Molten Armor
		116257, -- Invoker's Energy
	},
	WARLOCK = {
		1459, -- Arcane Brilliance
		61316, -- Dalaran Brilliance
		109773, -- Dark Intent
	},
	SHAMAN = {
		52127, -- Water Shield
		324, -- Lightning Shield
		974, -- Earth Shield
	},
	WARRIOR = {
		469, -- Commanding Shout
		6673, -- Battle Shout
		93435, -- Roar of Courage (Hunter Pet)
		57330, -- Horn of Winter
		21562, -- PW: Fortitude
	},
	DEATHKNIGHT = {
		57330, -- Horn of Winter
		6673, -- Battle Shout
		93435, -- Roar of Courage (Hunter Pet)
		49222, -- Bone Shield
	},
	ROGUE = {
		2823, -- Deadly Poison
		8679, -- Wound Poison
	},
	DRUID = {
		1126, -- Mark of the Wild
		20217, -- Blessing of Kings
		117666, -- Legacy of the Emperor
		90363, -- Embrace of the Shale Spider
	},
	PALADIN = {
		20217, -- Blessing of Kings
		1126, -- Mark of the Wild
		117666, -- Legacy of the Emperor
		90363, -- Embrace of the Shale Spider
		19740, -- Blessing of Might
	},
	MONK = {
		117666, -- Legacy of the Emperor
		20217, -- Blessing of Kings
		1126, -- Mark of the Wild
		90363, -- Embrace of the Shale Spider
		116781, -- Legacy of the White Tiger
	},
}

Last edited by liquidbase : 01-12-13 at 08:52 AM.
  Reply With Quote
01-12-13, 08:40 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Most likely, the list of spell IDs is out of date, so the addon is trying to get info about a spell that doesn't exist.

Also, that code is really inefficient. Change this part:
Code:
			local name = GetSpellInfo(buff)
			local usable, nomana = IsUsableSpell(name)
			if (usable or nomana) then
				self.icon:SetTexture(select(3, GetSpellInfo(buff)))
to this:
Code:
			local name, _, icon = GetSpellInfo(buff)
			local usable, nomana = IsUsableSpell(name)
			print(buff, name, usable, nomana)
			if (usable or nomana) then
				self.icon:SetTexture(icon)
This (a) fixes the glaring inefficiency of calling the same function twice in a row and adding an extra function call for select, and (b) adds a print statement so you can see in the chat frame which spell it's trying to display. When the black box appears, check the chat frame -- you should see a message like "12345 Spell Name 1 nil". Look up "Spell Name" on Wowhead and make sure that the number in the URL matches the "12345" number shown in the message. If it doesn't match, change "12345" in the table to the correct ID.
__________________
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
01-13-13, 05:42 AM   #3
liquidbase
A Warpwood Thunder Caller
 
liquidbase's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 97
Thanks for the input Phanx.
Yes I know the script is crap and needs a complete rewrite and I'm on it. With your change and current SpellIDs all works again and I can make myself to the rewrite of the script.

Thanks
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Problem with a buffnotice-script

Thread Tools
Display Modes

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