WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Nameplate Aura Filter (https://www.wowinterface.com/forums/showthread.php?t=59021)

Zaqqari 01-15-22 05:06 AM

Nameplate Aura Filter
 
Fizzlemizz helped me with an addon a while ago to filter the nameplate auras by spell ID, and it works great. The only thing I wish I could do with it is stop it from filtering friendly nameplates. By default, friendly nameplates show all dispellable debuffs. You can't modify friendly nameplates in dungeon and raid instances, so I'd like to keep the debuffs consistent by disabling the filter on friendly nameplates.

Also, forgive my ignorance, but is there anywhere I can find a list of everything you can do with the WoW API (e.g. INCLUDE_NAME_PLATE_ONLY, Mixin, BUFF_MAX_DISPLAY, UnitIsUnit, etc.)? I'm just guessing at what these things do without much success. I'd like to learn how to write my own addons from start to finish, but I don't really know where to find good information. Most of the links I find in guides are outdated or no longer active.

Code:

local whitelist = {

        [116841] = "player",--Tiger's Lust
        [228287] = "player",--Mark of the Crane
        [115078] = "all",--Paralysis
       
}

local function newShouldShowBuff(self, name, caster, nameplateShowPersonal, nameplateShowAll, duration)
        local filter = "INCLUDE_NAME_PLATE_ONLY"
        if UnitIsUnit(self.unit, "player") then
                filter = "HELPFUL|".. filter
        else
                filter = "HARMFUL|".. filter
        end
        for i=1, BUFF_MAX_DISPLAY do
                local spellName, _, _, _, spellDuration, _, spellCaster, _, _, spellId = UnitAura(self.unit, i, filter);
                if not spellName then break end
                if name == spellName and caster == spellCaster and duration == spellDuration then
                        if (caster and whitelist[spellId] == spellCaster) or whitelist[spellId] == "all" then
                                return true
                        end
                end
        end
        return false
end
local function Mixin(baseFrame)
        baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
end
local f = CreateFrame("Frame")
f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
f:SetScript("OnEvent", function(_,_,unitId)
        Mixin(C_NamePlate.GetNamePlateForUnit(unitId))
end)
for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
        Mixin(baseFrame)
end


Fizzlemizz 01-17-22 11:15 AM

You should be able to do something like changing:

Lua Code:
  1. local function Mixin(baseFrame)
  2.     baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  3. end
too:
Lua Code:
  1. local function Mixin(baseFrame)
  2.     if not UnitIsEnemy(baseFrame.UnitFrame.unit, "player") then return end
  3.     baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  4. end

So friendly units don't receive the filter. There may well be a better way.

For documentation, WowPedia is probably the best other than asking questions here or one of the other WoW UI focused websites like the WoW UI forum or Discord

Zaqqari 01-17-22 09:00 PM

Thanks so much for the response. It doesn't seem to work. All auras reset to default. Also, to clarify, I'd like my personal resource display to show whitelisted auras as well. I only want to ignore non-self friendly nameplates.

I replaced that function with:
Lua Code:
  1. local function Mixin(baseFrame)
  2.     if UnitIsFriend(baseFrame.UnitFrame.unit, "player") and not UnitIsUnit(baseFrame.UnitFrame.unit, "player")then return end
  3.     baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  4. end

It works for a bit, but then it starts filtering friendly nameplates again. I'm working on it, but not much luck.

Fizzlemizz 01-20-22 11:11 AM

You want the whitelist on your character and other friendly "players".

Everyone else has no buffs or everyone else has all buffs?

Zaqqari 01-20-22 11:39 PM

I want the whitelist to work on my personal resource display and enemy units. Because Blizzard made it so you can't modify friendly nameplates in dungeon and raid instances, I would like to ignore those units for consistency.

Self: Whitelisted buffs
Friendlies: Blizzard's default auras (ignored by the Lua script)
Enemies: Whitelisted debuffs

The script in my previous post works the way I want it to at first and then at some point begins filtering friendly nameplates. I've only tested it in random battlegrounds, if that helps.

Kanegasi 01-21-22 01:10 AM

Lua Code:
  1. local whitelist = {
  2.  
  3.     [116841] = "player", --Tiger's Lust
  4.     [228287] = "player", --Mark of the Crane
  5.     [115078] = "all", --Paralysis
  6.    
  7. }
  8.  
  9. local function replacefilter(unit)
  10.     C_NamePlate.GetNamePlateForUnit(unit).UnitFrame.BuffFrame.ShouldShowBuff=function(self,name,caster,nameplateShowPersonal,nameplateShowAll,duration)
  11.         if name then
  12.             local isPlayer=UnitIsUnit(self.unit,"player")
  13.             local isEnemy=UnitCanAttack(self.unit,"player")
  14.             local filter=isPlayer and "HELPFUL" or "HARMFUL"
  15.             if isPlayer or isEnemy then
  16.                 for i=1,BUFF_MAX_DISPLAY do
  17.                     local spellName,_,_,_,spellDuration,_,spellCaster,_,_,spellId=UnitAura(self.unit,i,filter)
  18.                     if not spellName then break end
  19.                     if name==spellName and caster==spellCaster and duration==spellDuration then
  20.                         if whitelist[spellId]==caster or whitelist[spellId]=="all" then
  21.                             return true
  22.                         end
  23.                     end
  24.                 end
  25.             else
  26.                 return nameplateShowAll or (nameplateShowPersonal and (caster=="player" or caster=="pet" or caster=="vehicle"))
  27.             end
  28.         end
  29.         return false
  30.     end
  31. end
  32. local f=CreateFrame("frame")
  33. f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  34. f:SetScript("OnEvent",function(_,_,unit) replacefilter(unit) end)

I had a go at reorganizing the code. Some notes:
  • Filtering friendly at function replacement won't work, since all 40 nameplate frames will eventually get the replacement due to frame pooling, so you have to filter within the replacement function.
  • Additionally, you don't have to worry about touching instanced friendly nameplates, separate events deal with separate secure frames while still maintaining a max of 40 nameplates active at once (e.g. FORBIDDEN_NAME_PLATE_CREATED)
  • The original ShouldShowBuff has a name==nil escape, which I think should still be included.
  • Since this is a usermade whitelist, INCLUDE_NAME_PLATE_ONLY should be dropped, or you may end up having an aura you want not show up if Blizzard decided it shouldn't show on nameplates.
  • From my experience with a personal addon dealing with attached nameplate frames, UnitIsFriend is not consistent with neutral units, so UnitCanAttack is used instead.
  • Finally, the long return line is from the original ShouldShowBuff, allowing friendly nameplates affected by this replaced function to behave as Blizzard's code intended.

NAME_PLATE_CREATED happens before UnitFrame is added, so stick with the original UNIT_ADDED event

Zaqqari 01-21-22 02:50 AM

Hey, thanks for the help! It's not working at all. It defaults back to Blizzards nameplate auras. Here is the error report from BugGrabber:

Lua Code:
  1. 21x ...eNameplateAuraFilter\NameplateAuraFilter-1.0.lua:1797: attempt to index field 'UnitFrame' (a nil value)
  2. [string "@NameplateAuraFilter\NameplateAuraFilter-1.0.lua"]:1797: in function <...eNameplateAuraFilter\NameplateAuraFilter.lua:1796>
  3. [string "@NameplateAuraFilter\NameplateAuraFilter-1.0.lua"]:1821: in function <...eNameplateAuraFilter\NameplateAuraFilter.lua:1821>
  4.  
  5. Locals:
  6. nameplate = NamePlate1 {
  7.  OnSizeChanged = <function> defined @Blizzard_NamePlates\Blizzard_NamePlates.lua:485
  8.  GetPreferredInsets = <function> defined @Blizzard_NamePlates\Blizzard_NamePlates.lua:466
  9.  GetAdditionalInsetPadding = <function> defined @Blizzard_NamePlates\Blizzard_NamePlates.lua:455
  10.  ApplyOffsets = <function> defined @Blizzard_NamePlates\Blizzard_NamePlates.lua:437
  11.  OnRemoved = <function> defined =[C]:-1
  12.  OnAdded = <function> defined =[C]:-1
  13.  template = "NamePlateUnitFrameTemplate"
  14.  0 = <userdata>
  15.  OnOptionsUpdated = <function> defined @Blizzard_NamePlates\Blizzard_NamePlates.lua:431
  16. }
  17. (*temporary) = nil
  18. (*temporary) = nil
  19. (*temporary) = "attempt to index field 'UnitFrame' (a nil value)"
  20. whitelist = <table> {
  21.  358259 = "all"
  22.  22703 = "all"
  23.  25771 = "all"
  24.  201158 = "all"
  25.  45334 = "all"
  26.  202274 = "all"
  27.  453 = "all"
  28.  221527 = "all"
  29.  31935 = "all"
  30.  208618 = "all"
  31.  206961 = "all"
  32.  200108 = "all"
  33.  211015 = "all"
  34.  317589 = "all"
  35.  202244 = "all"
  36.  331866 = "player"
  37.  324748 = "player"
  38.  212540 = "all"
  39.  118 = "all"
  40.  202914 = "all"
  41.  323996 = "all"
  42.  91800 = "all"
  43.  119611 = "player"
  44.  217832 = "all"
  45.  205369 = "all"
  46.  119381 = "all"
  47.  15487 = "all"
  48.  324263 = "all"
  49.  221562 = "all"
  50.  122783 = "player"
  51.  324867 = "player"
  52.  323524 = "player"
  53.  307871 = "all"
  54.  205147 = "player"
  55.  20066 = "all"
  56.  125174 = "player"
  57.  212638 = "all"
  58.  325886 = "all"
  59.  344021 = "player"
  60.  287254 = "all"
  61.  337341 = "player"
  62.  196733 = "player"
  63.  337571 = "player"
  64.  10326 = "all"
  65.  356567 = "all"
  66.  213691 = "all"
  67.  116680 = "player"
  68.  207736 = "all"
  69.  236273 = "all"
  70.  2094 = "all"
  71.  61305 = "all"
  72.  161353 = "all"
  73.  236077 = "all"
  74.  233582 = "all"
  75.  343294 = "all"
  76.  115804 = "player"
  77.  123725 = "player"
  78.  202090 = "player"
  79.  325190 = "player"
  80.  161354 = "all"
  81.  199085 = "all"
  82.  196608 = "player"
  83.  199845 = "all"
  84.  31661 = "all"
  85.  206649 = "all"
  86.  202346 = "all"
  87.  290512 = "player"
  88.  117526 = "all"
  89.  5211 = "all"
  90.  215479 = "player"
  91.  198819 = "all"
  92.  132169 = "all"
  93.  205630 = "all"
  94.  196737 = "player"
  95.  33395 = "all"
  96.  334693 = "all"
  97.  5246 = "all"
  98.  99 = "all"
  99.  213688 = "all"
  100.  408 = "all"
  101.  305485 = "all"
  102.  247483 = "player"
  103.  243435 = "player"
  104.  195630 = "player"
  105.  209584 = "player"
  106.  89766 = "all"
  107.  287712 = "all"
  108.  233395 = "all"
  109.  203337 = "all"
  110.  87204 = "all"
  111.  20549 = "all"
  112.  6789 = "all"
  113.  6358 = "all"
  114.  5484 = "all"
  115.  1098 = "all"
  116.  24394 = "all"
  117.  126819 = "all"
  118.  6770 = "all"
  119.  171017 = "all"
  120.  322459 = "all"
  121.  211881 = "all"
  122.  30283 = "all"
  123.  61721 = "all"
  124.  853 = "all"
  125.  196942 = "all"
  126.  196741 = "player"
  127.  325202 = "player"
  128.  269352 = "all"
  129.  28271 = "all"
  130.  122278 = "player"
  131.  323673 = "all"
  132.  211010 = "all"
  133.  1513 = "all"
  134.  137639 = "player"
  135.  353509 = "player"
  136.  2637 = "all"
  137.  132578 = "player"
  138.  1833 = "all"
  139.  19386 = "all"
  140.  353319 = "all"
  141.  197908 = "player"
  142.  116095 = "player"
  143.  196725 = "player"
  144.  202162 = "player"
  145.  204399 = "all"
  146.  9484 = "all"
  147.  197214 = "all"
  148.  123586 = "player"
  149.  207167 = "all"
  150.  209749 = "all"
  151.  277778 = "all"
  152.  353503 = "player"
  153.  204490 = "all"
  154.  91807 = "all"
  155.  118345 = "all"
  156.  77505 = "all"
  157.  64695 = "all"
  158.  82691 = "all"
  159.  212332 = "all"
  160.  51514 = "all"
  161.  191840 = "player"
  162.  324382 = "all"
  163.  162480 = "all"
  164.  248646 = "player"
  165.  1776 = "all"
  166.  1330 = "all"
  167.  212150 = "all"
  168.  207777 = "all"
  169.  345230 = "player"
  170.  196364 = "all"
  171.  41425 = "all"
  172.  132168 = "all"
  173.  200196 = "all"
  174.  199042 = "all"
  175.  277784 = "all"
  176.  102359 = "all"
  177.  64044 = "all"
  178.  205290 = "all"
  179.  179057 = "all"
  180.  605 = "all"
  181.  207171 = "all"
  182.  203123 = "all"
  183.  325216 = "player"
  184.  233022 = "all"
  185.  202335 = "player"
  186.  325153 = "player"
  187.  277787 = "all"
  188.  204080 = "all"
  189.  116847 = "player"
  190.  115078 = "all"
  191.  255941 = "all"
  192.  202933 = "all"
  193.  28272 = "all"
  194.  217824 = "all"
  195.  8122 = "all"
  196.  332423 = "all"
  197.  325092 = "player"
  198.  105771 = "all"
  199.  212337 = "all"
  200.  116768 = "player"
  201.  198121 = "all"
  202.  336887 = "player"
  203.  163505 = "all"
  204.  201787 = "player"
  205.  228287 = "player"
  206.  108194 = "all"
  207.  277792 = "all"
  208.  105421 = "all"
  209.  198909 = "all"
  210.  124280 = "player"
  211.  122470 = "player"
  212.  228563 = "player"
  213.  207685 = "all"
  214.  121253 = "player"
  215.  233759 = "all"
  216.  107079 = "all"
  217.  210873 = "all"
  218.  116706 = "all"
  219.  116189 = "player"
  220.  354540

Fizzlemizz 01-21-22 10:06 AM

Kanegasi makes valid points and may well be closer to best method. This is a rework of the original with just an "ignore" for non-player friendlies.
I've been scratching my head as to if/why I would have redefined Mixin like that but...
Lua Code:
  1. local whitelist = {
  2.     [116841] = "player",--Tiger's Lust
  3.     [228287] = "player",--Mark of the Crane
  4.     [115078] = "all",--Paralysis
  5.    
  6. }
  7.  
  8. local function newShouldShowBuff(self, name, caster, nameplateShowPersonal, nameplateShowAll, duration)
  9.     if not name then return false end
  10.     local filter = "INCLUDE_NAME_PLATE_ONLY"
  11.     if UnitIsUnit(self.unit, "player") then
  12.         filter = "HELPFUL|"..filter
  13.     elseif UnitIsFriend(self.unit, "player") then
  14.         return true
  15.     else
  16.         filter = "HARMFUL|"..filter
  17.     end
  18.     for i=1, BUFF_MAX_DISPLAY do
  19.         local spellName, _, _, _, spellDuration, _, spellCaster, _, _, spellId = UnitAura(self.unit, i, filter);
  20.         if not spellName then break end
  21.         if name == spellName and caster == spellCaster and duration == spellDuration then
  22.             if (caster and whitelist[spellId] == spellCaster) or whitelist[spellId] == "all" then
  23.                 return true
  24.             end
  25.         end
  26.     end
  27.     return false
  28. end
  29. local f = CreateFrame("Frame")
  30. f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  31. f:SetScript("OnEvent", function(_,_,unitId)
  32.     C_NamePlate.GetNamePlateForUnit(unitId).UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  33. end)
  34. for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
  35.     baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  36. end

Zaqqari 01-21-22 10:45 PM

Working perfectly, Fizzlemizz! Thanks both of you for the help, this is a huge improvement for my UI.

Zaqqari 01-22-22 05:41 PM

Sorry for re-posting, but I'm having another nameplate issue. I have a script that changes the width of nameplates, and it works as long as I'm not in combat when my interface is loaded. The nameplate settings are protected functions and cannot be modified in combat. A workaround for this might be to initiate the script whenever I leave combat in addition to when I load my interface for the first time. I'm trying to add PLAYER_LEAVE_COMBAT to PLAYER_LOGIN, but it's not working.

Lua Code:
  1. --Friendly/Enemy Nameplate Size--
  2. local f = CreateFrame("Frame")
  3. f:RegisterEvent("PLAYER_LOGIN")
  4. f:RegisterEvent("PLAYER_LEAVE_COMBAT")
  5. f:SetScript("OnEvent", function()
  6.    
  7.     nameplateSize()
  8.  
  9. end)
  10.  
  11. function nameplateSize()
  12.    
  13.     --Friendly Nameplate Size--
  14.     local FRIENDLY_NAMEPLATE_WIDTH = 85 --Percentage relative to default width.
  15.     local FRIENDLY_NAMEPLATE_HEIGHT = 100 --Percentage relative to default height.
  16.  
  17.  
  18.     local FNW = 110*(FRIENDLY_NAMEPLATE_WIDTH/100)
  19.  
  20.     local FNH = 45*(FRIENDLY_NAMEPLATE_HEIGHT/100)
  21.  
  22.     C_Timer.After(1, function() C_NamePlate.SetNamePlateFriendlySize(((FNH/45/2)*2.44444)/1.22222*FNW, 45) end);
  23.     local f = CreateFrame("Frame")
  24.     f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  25.     f:SetScript("OnEvent", function(self, event, unit)
  26.     if UnitIsFriend("player", unit) then
  27.     C_NamePlate.GetNamePlateForUnit(unit).UnitFrame:SetScale(FNH/45) --
  28.     else
  29.     end
  30.     end)
  31.  
  32.     --Enemy Nameplate Size--
  33.     local ENEMY_NAMEPLATE_WIDTH = 85 --Percentage relative to default width.
  34.     local ENEMY_NAMEPLATE_HEIGHT = 100 --Percentage relative to default height.
  35.  
  36.  
  37.     local FNW = 110*(ENEMY_NAMEPLATE_WIDTH/100)
  38.  
  39.     local FNH = 45*(ENEMY_NAMEPLATE_HEIGHT/100)
  40.  
  41.     C_Timer.After(1, function() C_NamePlate.SetNamePlateEnemySize(((FNH/45/2)*2.44444)/1.22222*FNW, 45) end);
  42.     local f = CreateFrame("Frame")
  43.     f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  44.     f:SetScript("OnEvent", function(self, event, unit)
  45.     if UnitIsEnemy("player", unit) then
  46.     C_NamePlate.GetNamePlateForUnit(unit).UnitFrame:SetScale(FNH/45) --
  47.     else
  48.     end
  49.     end)
  50.    
  51.     --Personal Nameplate Size--
  52.     local SELF_NAMEPLATE_WIDTH = 100 --Percentage relative to default width.
  53.     local SELF_NAMEPLATE_HEIGHT = 100 --Percentage relative to default height.
  54.  
  55.  
  56.     local FNW = 110*(SELF_NAMEPLATE_WIDTH/100)
  57.  
  58.     local FNH = 45*(SELF_NAMEPLATE_HEIGHT/100)
  59.  
  60.     C_Timer.After(1, function() C_NamePlate.SetNamePlateSelfSize(((FNH/45/2)*2.44444)/1.22222*FNW, 45) end);
  61.     local f = CreateFrame("Frame")
  62.     f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  63.     f:SetScript("OnEvent", function(self, event, unit)
  64.     if UnitIsEnemy("player", unit) then
  65.     C_NamePlate.GetNamePlateForUnit(unit).UnitFrame:SetScale(FNH/45) --
  66.     else
  67.     end
  68.     end)
  69.  
  70. end

EDIT: I got it working with PLAYER_REGEN_ENABLED, but I'm not sure that's always going to do the trick. There must be a better way to make the nameplates 85% of their normal width.

Kanegasi 01-22-22 09:10 PM

There's an issue with having this code happen every time you leave combat. You're creating three frames that listen to the same event every time. Eventually, over the course of a play session, you will have dozens, eventually hundreds, of triggers that lag your game every time a new nameplate appears.

Also, what is the purpose of the one second delays?

I reorganized your code so that only one frame is used. I'm assuming you want the SetScales to happen only when a nameplate appears and the three SetSizes to happen at login or end of combat. InCombatLockdown() reports true/false the status of UI combat protection, which turns on just a frame or so after PLAYER_REGEN_DISABLED and off a frame or so before PLAYER_REGEN_ENABLED.

Lua Code:
  1. --Friendly/Enemy Nameplate Size--
  2. local f=CreateFrame("frame")
  3.  
  4. --Personal Nameplate Size--
  5. f.SELF_NAMEPLATE_WIDTH = 100 --Percentage relative to default width.
  6. f.SELF_NAMEPLATE_HEIGHT = 100 --Percentage relative to default height.
  7. f.SNW = 110*(f.SELF_NAMEPLATE_WIDTH/100)
  8. f.SNH = 45*(f.SELF_NAMEPLATE_HEIGHT/100)
  9.  
  10. --Enemy Nameplate Size--
  11. f.ENEMY_NAMEPLATE_WIDTH = 85 --Percentage relative to default width.
  12. f.ENEMY_NAMEPLATE_HEIGHT = 100 --Percentage relative to default height.
  13. f.ENW = 110*(f.ENEMY_NAMEPLATE_WIDTH/100)
  14. f.ENH = 45*(f.ENEMY_NAMEPLATE_HEIGHT/100)
  15.  
  16. --Friendly Nameplate Size--
  17. f.FRIENDLY_NAMEPLATE_WIDTH = 85 --Percentage relative to default width.
  18. f.FRIENDLY_NAMEPLATE_HEIGHT = 100 --Percentage relative to default height.
  19. f.FNW = 110*(f.FRIENDLY_NAMEPLATE_WIDTH/100)
  20. f.FNH = 45*(f.FRIENDLY_NAMEPLATE_HEIGHT/100)
  21.  
  22. f:RegisterEvent("PLAYER_LOGIN")
  23. f:RegisterEvent("PLAYER_REGEN_ENABLED")
  24. f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  25. f:SetScript("OnEvent",function(self,event,unit)
  26.     if not InCombatLockdown() then
  27.         if unit then
  28.             if UnitIsUnit(unit,"player") then
  29.                 C_NamePlate.GetNamePlateForUnit(unit).UnitFrame:SetScale(self.SNH/45) --
  30.             elseif UnitCanAttack(unit,"player") then
  31.                 C_NamePlate.GetNamePlateForUnit(unit).UnitFrame:SetScale(self.ENH/45) --
  32.             else
  33.                 C_NamePlate.GetNamePlateForUnit(unit).UnitFrame:SetScale(self.FNH/45) --
  34.             end
  35.         end
  36.         C_NamePlate.SetNamePlateSelfSize(((self.SNH/45/2)*2.44444)/1.22222*self.SNW,45)
  37.         C_NamePlate.SetNamePlateEnemySize(((self.ENH/45/2)*2.44444)/1.22222*self.ENW,45)
  38.         C_NamePlate.SetNamePlateFriendlySize(((self.FNH/45/2)*2.44444)/1.22222*self.FNW,45)
  39.     end
  40. end)

Zaqqari 01-22-22 09:36 PM

Perhaps I should have been more clear. I didn't write the script, and I don't even remember where I found it. I eventually got it to work using OnUpdate at 0.1s intervals, but I don't know how optimal that is. I'm just learning this stuff from scratch, so most of it goes right over my head. I tried your script, and it's not working.

From BugSack:

Lua Code:
  1. 1x ZaqqUI\ZaqqUI-1.0.lua:7: attempt to perform arithmetic on global 'SELF_NAMEPLATE_WIDTH' (a nil value)
  2. [string "@ZaqqUI\ZaqqUI-1.0.lua"]:7: in main chunk
  3.  
  4. Locals:
  5. f = <unnamed> {
  6.  SELF_NAMEPLATE_WIDTH = 100
  7.  SELF_NAMEPLATE_HEIGHT = 100
  8.  0 = <userdata>
  9. }
  10. (*temporary) = nil
  11. (*temporary) = <unnamed> {
  12.  SELF_NAMEPLATE_WIDTH = 100
  13.  SELF_NAMEPLATE_HEIGHT = 100
  14.  0 = <userdata>
  15. }
  16. (*temporary) = nil
  17. (*temporary) = <userdata>
  18. (*temporary) = "attempt to perform arithmetic on global 'SELF_NAMEPLATE_WIDTH' (a nil value)"

Kanegasi 01-22-22 11:40 PM

Oops, missed some frame references to your variables that used to be local. Probably could've kept those local. My base goal with those was to put the three letter variables into indexes of the frame.

I edited my code above. I also shifted the setsizes around so that they happen every registered event.

Zaqqari 01-23-22 06:06 PM

After testing it for a while, it's been working consistently, and it doesn't revert to default width anymore. Thanks for all your help again, and I hope this is useful to someone else as well.

Zaqqari 03-24-22 11:27 PM

This addon has stopped working recently. It shows no auras on nameplates. BugGrabber is not getting anything.

Lua Code:
  1. local whitelist = {
  2.     [SpellID] = "player",--Aura Name
  3.     [SpellID] = "pet",--Aura Name
  4.     [SpellID] = "all",--Aura Name
  5.    
  6. }
  7.  
  8. local function newShouldShowBuff(self, name, caster, nameplateShowPersonal, nameplateShowAll, duration)
  9.     if not name then return false end
  10.     local filter = "INCLUDE_NAME_PLATE_ONLY"
  11.     if UnitIsUnit(self.unit, "player") then
  12.         filter = "HELPFUL|"..filter
  13.     elseif UnitIsFriend(self.unit, "player") then
  14.         return true
  15.     else
  16.         filter = "HARMFUL|"..filter
  17.     end
  18.     for i=1, BUFF_MAX_DISPLAY do
  19.         local spellName, _, _, _, spellDuration, _, spellCaster, _, _, spellId = UnitAura(self.unit, i, filter);
  20.         if not spellName then break end
  21.         if name == spellName and caster == spellCaster and duration == spellDuration then
  22.             if (caster and whitelist[spellId] == spellCaster) or whitelist[spellId] == "all" then
  23.                 return true
  24.             end
  25.         end
  26.     end
  27.     return false
  28. end
  29. local f = CreateFrame("Frame")
  30. f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  31. f:SetScript("OnEvent", function(_,_,unitId)
  32.     C_NamePlate.GetNamePlateForUnit(unitId).UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  33. end)
  34. for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
  35.     baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
  36. end

I think this could have something to do with it(?):
https://us.forums.blizzard.com/en/wo...ations/1205007


All times are GMT -6. The time now is 12:17 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI