Quantcast
WoWInterface - View Single Post - Nameplate's castbar won't change its texture
View Single Post
11-01-18, 01:10 AM   #2
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 46
I've also tried something like this:

Lua Code:
  1. ------------------------------------------
  2. -- Variable
  3. ------------------------------------------
  4.  
  5. local LSM = LibStub("LibSharedMedia-3.0");
  6. local fontA = LSM:Fetch("font", "fontA");
  7. local textureB = LSM:Fetch("statusbar", "textureB");
  8.  
  9. local UpdateMedia;
  10. local CreateAuraFrame;
  11. local CreateHealthText;
  12.  
  13. local OnEvent;
  14.  
  15. ------------------------------------------
  16. -- Function
  17. ------------------------------------------
  18.  
  19. function UpdateMedia(nameplate)
  20.     local unitFrame = nameplate.UnitFrame;
  21.  
  22.     local name = unitFrame.name;
  23.     if (name) then
  24.         name:SetFont(fontA, 14, "OUTLINE");
  25.     end
  26.  
  27.     local healthBar = unitFrame.healthBar;
  28.     if (healthBar) then
  29.         healthBar:SetStatusBarTexture(textureB);
  30.     end
  31.  
  32.     local castBar = unitFrame.castBar;
  33.     if (castBar) then
  34.         castBar._SetStatusBarTexture = castBar.SetStatusBarTexture;
  35.         castBar:SetStatusBarTexture(textureB);
  36.         castBar.SetStatusBarTexture = function(...) end;
  37.  
  38.         castBar.Text:SetFont(fontA, 12, "OUTLINE");
  39.     end
  40. end
  41.  
  42. function OnEvent(self, event, ...)
  43.     if (event == "NAME_PLATE_CREATED") then
  44.         local nameplate = ...;
  45.         if (nameplate and nameplate.UnitFrame) then
  46.             UpdateMedia(nameplate);
  47.             -- CreateAuraFrame(nameplate);
  48.             -- CreateHealthText(nameplate);
  49.         end
  50.     end
  51. end
  52.  
  53. local handler = CreateFrame("Frame");
  54. handler:RegisterEvent("NAME_PLATE_CREATED");
  55. handler:RegisterEvent("NAME_PLATE_UNIT_ADDED");
  56. handler:RegisterEvent("NAME_PLATE_UNIT_REMOVED");
  57. handler:SetScript("OnEvent", OnEvent);

So, on nameplate creation, the SetStatusBarTexture is backed up with a name _SetStatusBarTexture, call SetStatusBarTexture then SetStatusBarTexture is now set to empty function.

This worked fine when the player is not in the combat, but once the player is in the combat, it causes the following error.

Code:
1x [ADDON_ACTION_BLOCKED] AddOn 'LyakNameplate' tried to call the protected function 'SetTargetClampingInsets()'
Would there be any secure way to tweak the texture of nameplate's castbar...?
  Reply With Quote