View Single Post
12-15-13, 05:05 AM   #14
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Okay, I gave up and spent some time looking through Stuf's code. The problem is that it doesn't create its frames right away when it loads. To fix that, you'll need to use function hooks to detect when Stuf creates the frames. Replace your OnLoad scripts with this (change the blue part at the top for each panel):
Code:
self.unit = "party1"
self.frame = _G["Stuf.units." .. self.unit]

self.initFunc = function()
	self:RegisterEvent("PLAYER_TARGET_CHANGED")
	self.frame:HookScript("OnEnter", function()
		self:Show()
	end)
	self.frame:HookScript("OnLeave", function()
		if not UnitIsUnit("target", self.unit) then
			self:Hide()
		end
	end)
end

if self.frame then
	self.initFunc()
else
	hooksecurefunc(Stuf, "CreateUnitFrame", function()
		-- Can't undo hooksecurefunc. Make sure it only initializes once.
		if self.frame then return end
		self.frame = _G["Stuf.units." .. self.unit]
		if self.frame then
			self.initFunc()
		end
	end)
end
__________________
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 : 12-15-13 at 06:41 AM.
  Reply With Quote