WoWInterface

WoWInterface (http://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (http://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   focustarget targetting event (http://www.wowinterface.com/forums/showthread.php?t=45550)

10leej 01-01-13 10:14 PM

focustarget targetting event (solved)
 
So trying to add the !beautycase border to the focus target frame and I figured

"Well if I just run FocusFrameToTPortraitModel:CreateBorder(8,1,1,1) all I'm gonna get is

"Message: Interface\AddOns\BobUI\modules\unitframes.lua:647: attempt to index global 'FocusFrameToTPortraitModel' (a nil value)"

So I should probably make a script looking like this

Lua Code:
  1. local w = CreateFrame("Frame")
  2. w:RegisterEvent("PLAYER_FOCUS_CHANGED")
  3. function w:OnEvent(event, ...)
  4.   event == "PLAYER_FOCUS_CHANGED" then
  5.   FocusFrameToTPortraitModel:CreateBorder(8,1,1,1)
  6. end
  7. w:SetScript("OnEvent", w.OnEvent)

So add that stuff to my addon (whoa unitframes btw) and low and behold I still get

"Message: Interface\AddOns\BobUI\modules\unitframes.lua:647: attempt to index global 'FocusFrameToTPortraitModel' (a nil value)"

when I add a focus something for the first time, but anytime after I do that it works perfectly

So i figured "I must be using the wrong event"

but alas "PLAYER_FOCUS_CHANGED" the only event I found pertaining to the focus target

and now I'm all like "I need more helpz" so i dialed my buddies here at wowinterface and made a thread

FocusFrameToTPortraitModel is the frame created by adapt for the 3d portraits.

semlar 01-01-13 10:29 PM

Why don't you just modify Adapt to add the border if it's creating the frame?

I guess you could do something like wait for ADDON_LOADED and watch for Adapt, then call

Lua Code:
  1. hooksecurefunc(Adapt, 'CreateModel', function(texture)
  2.   if texture:GetName() ~= "FocusFrameToTPortrait" then return end
  3.   -- do stuff
  4. end)

10leej 01-01-13 10:44 PM

Quote:

Originally Posted by semlar (Post 271245)
Why don't you just modify Adapt to add the border if it's creating the frame?

I guess you could do something like wait for ADDON_LOADED and watch for Adapt, then call

Lua Code:
  1. hooksecurefunc(Adapt, 'CreateModel', function(texture)
  2.   if texture:GetName() ~= "FocusFrameToTPortrait" then return end
  3.   -- do stuff
  4. end)

Cause I'd have to reapply the changes if Gello was to change it

humfras 01-02-13 06:08 AM

Quote:

Originally Posted by 10leej (Post 271246)
Cause I'd have to reapply the changes if Gello was to change it

Then simply add the EventRegister into the hookfunc.

Lua Code:
  1. local w = CreateFrame("Frame")
  2. function w:OnEvent(event, ...)
  3.  
  4.   event == "PLAYER_FOCUS_CHANGED" then
  5.  
  6.   FocusFrameToTPortraitModel:CreateBorder(8,1,1,1)
  7.  
  8. end
  9. w:SetScript("OnEvent", w.OnEvent)
  10.  
  11. hooksecurefunc(Adapt, 'CreateModel', function(texture)
  12.  
  13.   if texture:GetName() ~= "FocusFrameToTPortrait" then return end
  14.  
  15.   FocusFrameToTPortraitModel:CreateBorder(8,1,1,1)
  16.  
  17.   w:RegisterEvent("PLAYER_FOCUS_CHANGED")
  18.  
  19. end)


All times are GMT -6. The time now is 03:13 AM.

vBulletin © 2014, Jelsoft Enterprises Ltd
©2012 ZAM Network LLC