View Single Post
05-27-18, 12:42 PM   #7
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
I don't think it's related to Blizzard ArenaUI, they are changing the name on the default nameplates, according to the unit ID (which I assume would still be arena1/arena2/arena3/etc. regardless of ArenaUI being loaded.)

CompactUnitFrame is not an addon, so you can't really check for it with ADDON_LOADED, and Blizzard_NamePlates is not load on demand, so I would hope that this is already loaded by the time player-made addons are loaded (I don't think this would matter anyway; if nameplates weren't loaded, the code does not edit anything nameplate-specific anyway. It just happens to also work on nameplates, when those are present.)

I'm pretty sure the issue was that they had this code running concurrently, and both hooks may have been fighting over who gets to apply the change to the nameplate name:

lua Code:
  1. hooksecurefunc("CompactUnitFrame_UpdateName", function(frame)
  2.     if not frame:IsForbidden() then
  3.         local name, _ = UnitName(frame.unit)
  4.         frame.name:SetText(name)
  5.     end
  6. end)

For readability purposes here is the same code from the OP, re-factored and indented:

lua Code:
  1. hooksecurefunc("CompactUnitFrame_UpdateName", function(frame)
  2.     if IsActiveBattlefieldArena() and frame.unit:find("nameplate") then
  3.         for i=1,5 do
  4.             if UnitIsUnit(frame.unit,"arena"..i) then
  5.                 frame.name:SetText(i)
  6.                 frame.name:SetTextColor(1,1,0)
  7.                 break
  8.             end
  9.         end
  10.     end
  11. end)

Last edited by Ammako : 05-27-18 at 12:54 PM.
  Reply With Quote