View Single Post
04-26-14, 10:49 AM   #46
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Got the error to stop.

Had to switch the code up a little.

From this:
Lua Code:
  1. local petButtons = { "PetActionButton", "PossessButton", "ShapeshiftButton" }
  2.     hooksecurefunc("PetActionBar_Update",  function()
  3.         for i = 1, #petButtons do
  4.             for j = 1, 12 do
  5.                 local button = _G[petButtons[i]..j]
  6.                 button:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
  7.  
  8.                 AddRegionKeys(button)
  9.  
  10.                 local icon = button.icon
  11.                 icon:SetTexCoord(.05, .95, .05, .95)
  12.                 icon:ClearAllPoints()
  13.                 icon:SetPoint("TOPLEFT", -1, 1)
  14.                 icon:SetPoint("BOTTOMRIGHT", 1, -1)
  15.  
  16.                 local normalTexture = button.__normalTexture2 or button.__normalTexture
  17.                 normalTexture:ClearAllPoints()
  18.                 normalTexture:SetPoint("TOPLEFT", -15, 15)
  19.                 normalTexture:SetPoint("BOTTOMRIGHT",15, -15)
  20.  
  21.                 ColorButton(normalTexture)
  22.             end
  23.         end
  24.     end)

To this:
Lua Code:
  1. hooksecurefunc("PetActionBar_Update",  function()
  2.         for i = 1, NUM_PET_ACTION_SLOTS, 1 do
  3.             local buttonName = _G["PetActionButton"..i]
  4.             if buttonName then
  5.                 buttonName:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
  6.                 local iconName = _G["PetActionButton"..i.."Icon"];
  7.                 iconName:SetTexCoord(.05, .95, .05, .95);
  8.                 iconName:SetPoint("TOPLEFT", buttonName, -1, 1);
  9.                 iconName:SetPoint("BOTTOMRIGHT", buttonName, 1, -1);
  10.                 local buttonOutline = _G["PetActionButton"..i.."NormalTexture2"] or _G["PetActionButton"..i.."NormalTexture"]
  11.                 buttonOutline:ClearAllPoints()
  12.                 buttonOutline:SetPoint("TOPLEFT", buttonName, -15, 15)
  13.                 buttonOutline:SetPoint("BOTTOMRIGHT", buttonName, 15, -15)
  14.                 if db.misc.classcolor ~= true then
  15.                     buttonOutline:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b)
  16.                 else
  17.                     buttonOutline:SetVertexColor((classColor.r * 1.2), (classColor.g * 1.2), (classColor.b * 1.2))
  18.                 end                
  19.             end
  20.         end
  21.     end);  
  22.  
  23.     hooksecurefunc("PossessBar_UpdateState",  function()
  24.         for i = 1, NUM_POSSESS_SLOTS do
  25.             local buttonName = _G["PossessButton"..i]
  26.             if buttonName then
  27.                 buttonName:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
  28.                 local iconName = _G["PossessButton"..i.."Icon"];
  29.                 iconName:SetTexCoord(.05, .95, .05, .95);
  30.                 iconName:SetPoint("TOPLEFT", buttonName, -1, 1);
  31.                 iconName:SetPoint("BOTTOMRIGHT", buttonName, 1, -1);
  32.                 local buttonOutline = _G["PossessButton"..i.."NormalTexture2"] or _G["PossessButton"..i.."NormalTexture"]
  33.                 buttonOutline:ClearAllPoints()
  34.                 buttonOutline:SetPoint("TOPLEFT", buttonName, -15, 15)
  35.                 buttonOutline:SetPoint("BOTTOMRIGHT", buttonName, 15, -15)
  36.                 if db.misc.classcolor ~= true then
  37.                     buttonOutline:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b)
  38.                 else
  39.                     buttonOutline:SetVertexColor((classColor.r * 1.2), (classColor.g * 1.2), (classColor.b * 1.2))
  40.                 end                
  41.             end
  42.         end
  43.     end);
  44.    
  45.     hooksecurefunc("StanceBar_UpdateState",  function()
  46.         for i = 1, NUM_STANCE_SLOTS do
  47.             local buttonName = _G["StanceButton"..i]
  48.             if buttonName then
  49.                 buttonName:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
  50.                 local iconName = _G["StanceButton"..i.."Icon"];
  51.                 iconName:SetTexCoord(.05, .95, .05, .95);
  52.                 iconName:SetPoint("TOPLEFT", buttonName, -1, 1);
  53.                 iconName:SetPoint("BOTTOMRIGHT", buttonName, 1, -1);
  54.                 local buttonOutline = _G["StanceButton"..i.."NormalTexture2"] or _G["StanceButton"..i.."NormalTexture"]
  55.                 buttonOutline:ClearAllPoints()
  56.                 buttonOutline:SetPoint("TOPLEFT", buttonName, -15, 15)
  57.                 buttonOutline:SetPoint("BOTTOMRIGHT", buttonName, 15, -15)
  58.                 if db.misc.classcolor ~= true then
  59.                     buttonOutline:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b)
  60.                 else
  61.                     buttonOutline:SetVertexColor((classColor.r * 1.2), (classColor.g * 1.2), (classColor.b * 1.2))
  62.                 end                
  63.             end
  64.         end            
  65.     end);

I'm sure its not as efficant as Phanx's code but this way I do not get errors (yet) also not sure why but the petstancebutton needs for i=1, NUM_SLOTS, 1 do which the other 2 do not, and the ShapeshiftButton needed to be switched to StanceButton.

Coke
  Reply With Quote