View Single Post
04-16-19, 09:56 AM   #13
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Lua Code:
  1. local function CreateBorder(self)
  2.     local t = self.Border or self:CreateTexture(nil, "BACKGROUND", nil, -8)
  3.     self.Border = t
  4.      
  5.     ft:SetPoint("CENTER", 110, -350)
  6.     ft.Border = ft:CreateTexture("$parent_Border", "BORDER")
  7.     ft.Border:SetPoint("TOPLEFT", -6, 4)
  8.     ft.Border:SetPoint("BOTTOMRIGHT", 6, -10)
  9.     ft.Border:SetVertexColor(1, 1, 0, 1)
  10.      
  11.     self:RegisterEvent("PLAYER_TARGET_CHANGED")
  12.     self:HookScript("OnEvent", OnEvent)
  13. end

As well as at local t = ..., this function also is creating a new texture for ft.Border every time it is called
Code:
ft.Border = ft:CreateTexture("$parent_Border", "BORDER")
You adjust (SetPoint), create and color/adjust again ft but not t so self.Border (t) never gets placed anywhere on screen meaning you can't see the changes. For such a small amount of code you might get rid of "t" and "ft" and just use "self".

I'm not sure why you need to use the function and test if the self.Border texture exists if this is only for the target frame. If it's being called for multiple frames, especially if you have more functions like this, you are adding more and more hooks to OnEvent each time.

You might want to think about using a single frame to process all events (no hooks) and use that to make changes to the individual unit frames as required rather than multiple event handlers possibly processing the same event(s), not to mention keeping track of which handler(s) need updating when code changes.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-16-19 at 01:31 PM.
  Reply With Quote