Quantcast
WoWInterface - View Single Post - how to disable oUF element by conditionals
View Single Post
01-14-13, 07:38 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Get the latest version of oUF from Haste's GitHub repository, by clicking the "ZIP" button here:
https://github.com/haste/ouf

However, you will still get another version of the same error with the current version of oUF, because your code is defining a ClassIcons member for all classes, instead of only defining it if you actually create the frames.

Here is a stripped-down version of your code that should help you see the problem:
Code:
local ClassIcons = {}
if myClass == "MONK" or myClass == "PRIEST" or myClass == "PALADIN"  then
	for index = 1, 5 do
		local Icon = CreateFrame("Frame", "coldCI"..index, self)
		ClassIcons[index] = Icon
	end
end
self.ClassIcons = ClassIcons
As you can see, if the class isn't monk, priest, or paladin, no icons get added to the ClassIcons table, but the table still gets attached to the frame, so oUF sees the element, and tries to handle it, but fails because you didn't add the required internals.

Change your code to something more like this to solve the problem:
Code:
if myClass == "MONK" or myClass == "PRIEST" or myClass == "PALADIN"  then      
	local ClassIcons = {} -- only create this if the class is right
	for index = 1, 5 do
		local Icon = CreateFrame("Frame", "coldCI"..index, self)
		ClassIcons[index] = Icon
	end
	self.ClassIcons = ClassIcons -- only set this if the class is right
end
On a side note, I would recommend not giving global names to each icon, or to any other elements of your frame. You can access them faster by table lookups -- eg. frame.ClassIcons[4] -- without cluttering up the global namespace. If you really think you need globals for some reason, at least give them descriptive names, eg. "oUF_Cold_ClassIcon5" is far better than "coldCI5" because it actually tells the user what the frame is and which addon it belongs to.
__________________
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 : 01-14-13 at 07:40 PM.
  Reply With Quote