Quantcast WoWInterface - View Single Post - [PTR,7.1] Nameplate Color Change causes lua error in combat.
View Single Post
10-12-16, 05:01 PM   #5
thomasjohnshannon
A Theradrim Guardian
 
thomasjohnshannon's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 60
I made a quick video to show what is going on. In Colorz if I comment out "UnitSelectionColor = GameTooltip_UnitColor" it will stop the error but as said in my first post it doesn't seem to matter what method you are using.

My nameplate addon hooks CompactUnitFrame_UpdateHealthColor with the following code.

Lua Code:
  1. hooksecurefunc("CompactUnitFrame_UpdateHealthColor", function(frame)
  2.     if ( not nPlates.FrameIsNameplate(frame) ) then return end
  3.  
  4.     if ( not UnitIsConnected(frame.unit) ) then
  5.         local r, g, b = 0.5, 0.5, 0.5
  6.     else
  7.         if ( frame.optionTable.healthBarColorOverride ) then
  8.             local healthBarColorOverride = frame.optionTable.healthBarColorOverride
  9.             r, g, b = healthBarColorOverride.r, healthBarColorOverride.g, healthBarColorOverride.b
  10.         else
  11.             local localizedClass, englishClass = UnitClass(frame.unit)
  12.             local classColor = RAID_CLASS_COLORS[englishClass]
  13.             if ( UnitIsPlayer(frame.unit) and classColor and frame.optionTable.useClassColors ) then
  14.                     r, g, b = classColor.r, classColor.g, classColor.b
  15.             elseif ( CompactUnitFrame_IsTapDenied(frame) ) then
  16.                 r, g, b = 0.1, 0.1, 0.1
  17.             elseif ( frame.optionTable.colorHealthBySelection ) then
  18.                 if ( frame.optionTable.considerSelectionInCombatAsHostile and CompactUnitFrame_IsOnThreatListWithPlayer(frame.displayedUnit) ) then
  19.                     if ( nPlatesDB.TankMode ) then
  20.                         local target = frame.displayedUnit.."target"
  21.                         local isTanking, threatStatus = UnitDetailedThreatSituation("player", frame.displayedUnit)
  22.                         if ( isTanking and threatStatus ) then
  23.                             if ( threatStatus >= 3 ) then
  24.                                 r, g, b = 0.0, 1.0, 0.0
  25.                             elseif ( threatStatus == 2 ) then
  26.                                 r, g, b = 1.0, 0.6, 0.2
  27.                             end
  28.                         elseif ( nPlates.UseOffTankColor(target) ) then
  29.                             r, g, b = nPlatesDB.OffTankColor.r, nPlatesDB.OffTankColor.g, nPlatesDB.OffTankColor.b
  30.                         else
  31.                             r, g, b = 1.0, 0.0, 0.0;
  32.                         end
  33.                     else
  34.                         r, g, b = 1.0, 0.0, 0.0;
  35.                     end
  36.                 else
  37.                     r, g, b = UnitSelectionColor(frame.unit, frame.optionTable.colorHealthWithExtendedColors)
  38.                 end
  39.             elseif ( UnitIsFriend("player", frame.unit) ) then
  40.                 r, g, b = 0.0, 1.0, 0.0
  41.             else
  42.                 r, g, b = 1.0, 0.0, 0.0
  43.             end
  44.         end
  45.     end
  46.  
  47.         -- Execute Range Coloring
  48.  
  49.     if ( nPlatesDB.ShowExecuteRange and nPlates.IsInExecuteRange(frame) ) then
  50.         r, g, b = nPlatesDB.ExecuteColor.r, nPlatesDB.ExecuteColor.g, nPlatesDB.ExecuteColor.b
  51.     end
  52.  
  53.     if ( r ~= frame.healthBar.r or g ~= frame.healthBar.g or b ~= frame.healthBar.b ) then
  54.         frame.healthBar:SetStatusBarColor(r, g, b)
  55.  
  56.         if ( frame.optionTable.colorHealthWithExtendedColors ) then
  57.             frame.selectionHighlight:SetVertexColor(r, g, b)
  58.         else
  59.             frame.selectionHighlight:SetVertexColor(1, 1, 1)
  60.         end
  61.  
  62.         frame.healthBar.r, frame.healthBar.g, frame.healthBar.b = r, g, b
  63.     end
  64.  
  65.         -- Healthbar Border Coloring
  66.  
  67.     if ( frame.healthBar.beautyBorder ) then
  68.         for i = 1, 8 do
  69.             if ( UnitIsUnit(frame.displayedUnit, "target") ) then
  70.                 frame.healthBar.beautyBorder[i]:SetVertexColor(r,g,b,1)
  71.             else
  72.                 frame.healthBar.beautyBorder[i]:SetVertexColor(unpack(borderColor))
  73.             end
  74.         end
  75.     end
  76. end)

If you comment out "frame.healthBar.r, frame.healthBar.g, frame.healthBar.b = r, g, b" from the code the error is gone but since that is the code that actually sets the color it doesn't work without it.
__________________
Thomas aka Urnn