Thread Tools Display Modes
04-25-14, 01:09 PM   #41
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
I think I found another part of my UI that is a secure frame issue that causes the error:


Actionbars_Old there are secure hooks in here but I have learned that they need to have a if im in combat not to fire function.

So I changed it to this (InCombat code from Phanx)
Actionbars_New.

Is this correct?

Coke
  Reply With Quote
04-25-14, 06:31 PM   #42
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
http://pastebin.com/aJJqCHw9

Some of those copied action button functions were... really inefficient, creating new tables on every action button update, performing the same function call or global lookup 5 times in a row instead of storing the result in a variable, etc.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
04-25-14, 07:12 PM   #43
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Phanx View Post
http://pastebin.com/aJJqCHw9

Some of those copied action button functions were... really inefficient, creating new tables on every action button update, performing the same function call or global lookup 5 times in a row instead of storing the result in a variable, etc.
Changed code (thanks for the revamp again) and seem to be getting a error on the:
Code:
----------------------------------------------------------------------------------------
78.	local extraActionButtons = setmetatable({}, { __index = function(t, self)
79.		local name = AddRegionKeys(self)
80.		local v = not not strmatch(name, "ExtraActionButton")
81.		t[f] = v
82.		return v
83.	end })
----------------------------------------------------------------------------------------
103.	hooksecurefunc("ActionButton_UpdateUsable", function(self)
104.		if extraActionButtons[self] then return end
105.		ColorButton(self.__normalTexture)
106.	end)
----------------------------------------------------------------------------------------
The above code is the 2 sections from BasicUI as the code below states.

Here is the error:
Code:
1200x BasicUI-5.4.7\Modules\Actionbars.lua:81: table index is nil
BasicUI-5.4.7\Modules\Actionbars.lua:81: in function <BasicUI\Modules\Actionbars.lua:78>
BasicUI-5.4.7\Modules\Actionbars.lua:104: in function <BasicUI\Modules\Actionbars.lua:103>
<in C code>
<in C code>
FrameXML\ActionButton.lua:271: in function <FrameXML\ActionButton.lua:253>
<in C code>
FrameXML\ActionButton.lua:523: in function "ActionButton_OnEvent"
FrameXML\ActionButton.lua:124: in function <FrameXML\ActionButton.lua:117>
<in C code>
Buffet\Buffet-5.2.0.42.lua:127: in function "Edit"
Buffet\Buffet-5.2.0.42.lua:109: in function "Scan"
Buffet\Buffet-5.2.0.42.lua:61: in function <Buffet\Buffet.lua:54>
(tail call): ?

Locals:
self = MultiBarLeftButton6 {
 0 = <userdata>
 action = 42
 buttonType = "MULTIACTIONBAR4BUTTON"
 flashing = 0
 __hotkey = MultiBarLeftButton6HotKey {
 }
 __checkedTexture = <unnamed> {
 }
 flashtime = 0
 icon = MultiBarLeftButton6Icon {
 }
 __name = MultiBarLeftButton6Name {
 }
 feedback_action = 42
 __pushedTexture = <unnamed> {
 }
 __highlightTexture = <unnamed> {
 }
 __flash = MultiBarLeftButton6Flash {
 }
 __normalTexture = MultiBarLeftButton6NormalTexture {
 }
 __border = MultiBarLeftButton6Border {
 }
 FlyoutBorderShadow = MultiBarLeftButton6FlyoutBorderShadow {
 }
 FlyoutBorder = MultiBarLeftButton6FlyoutBorder {
 }
 __count = MultiBarLeftButton6Count {
 }
 eventsRegistered = true
 FlyoutArrow = MultiBarLeftButton6FlyoutArrow {
 }
 cooldown = MultiBarLeftButton6Cooldown {
 }
 rangeTimer = -1
}
(*temporary) = <table> {
}
(*temporary) = nil
extraActionButtons = <table> {
}
ColorButton = <function> defined @Interface\AddOns\BasicUI\Modules\Actionbars.lua:69
Coke

EDIT: This error also:
Code:
2x BasicUI-5.4.7\Modules\Actionbars.lua:118: attempt to index local "button" (a nil value)
BasicUI-5.4.7\Modules\Actionbars.lua:118: in function <BasicUI\Modules\Actionbars.lua:114>
<in C code>
FrameXML\PetActionBarFrame.lua:52: in function <FrameXML\PetActionBarFrame.lua:40>

Locals:
(*temporary) = <function> defined =[C]:-1
 = <function> defined @Interface\FrameXML\PetActionBarFrame.lua:106
 = <function> defined @Interface\AddOns\BasicUI\Modules\Actionbars.lua:114

and the code is:
Code:
	
113.local petButtons = { "PetActionButton", "PossessButton", "ShapeshiftButton" }
114.	hooksecurefunc("PetActionBar_Update",  function()
115.		for i = 1, #petButtons do
116.			for j = 1, 12 do
117.				local button = _G[petButtons[i]..j]
118.				button:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
119.
120.				AddRegionKeys(button)
121.
122.				local icon = button.icon
123.				icon:SetTexCoord(.05, .95, .05, .95)
124.				icon:ClearAllPoints()
125.				icon:SetPoint("TOPLEFT", -1, 1)
126.				icon:SetPoint("BOTTOMRIGHT", 1, -1)
127.
128.				local normalTexture = button.__normalTexture2 or button.__normalTexture
129.				normalTexture:ClearAllPoints()
130.				normalTexture:SetPoint("TOPLEFT", -15, 15)
131.				normalTexture:SetPoint("BOTTOMRIGHT",15, -15)
132.
133.				ColorButton(normalTexture)
134.			end
135.		end
136.	end)

Last edited by cokedrivers : 04-25-14 at 07:22 PM.
  Reply With Quote
04-26-14, 08:20 AM   #44
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
#1 - Change "t[f] = v" to "t[self] = v"

#2 - That means one of the bars you're modifying doesn't actually have 12 buttons. The whole section seems like it's probably not the best way to go about things, but I don't really feel like digging through the Blizzard actionbar code to rewrite it for you, so just do this to avoid the error:

Code:
	hooksecurefunc("PetActionBar_Update",  function()
		for i = 1, #petButtons do
			for j = 1, 12 do
				local name = petButtons[i] .. j
				local button = _G[name]
				if button then
					button:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
				
					-- all the stuff here is fine, just indent it by one more level

					ColorButton(normalTexture)
				else
					print(name, "doesn't exist") -- you can remove this later
				end
			end
		end
	end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
04-26-14, 08:41 AM   #45
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Phanx View Post
#1 - Change "t[f] = v" to "t[self] = v"

#2 - That means one of the bars you're modifying doesn't actually have 12 buttons. The whole section seems like it's probably not the best way to go about things, but I don't really feel like digging through the Blizzard actionbar code to rewrite it for you, so just do this to avoid the error:

Code:
	hooksecurefunc("PetActionBar_Update",  function()
		for i = 1, #petButtons do
			for j = 1, 12 do
				local name = petButtons[i] .. j
				local button = _G[name]
				if button then
					button:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
				
					-- all the stuff here is fine, just indent it by one more level

					ColorButton(normalTexture)
				else
					print(name, "doesn't exist") -- you can remove this later
				end
			end
		end
	end)
Yet again thank you, and I will stop bugging you about my addon, I'm sure your getting irritated with all my questions and needs.

Coke
  Reply With Quote
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
04-26-14, 10:20 PM   #47
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by cokedrivers View Post
... not sure why but the petstancebutton needs for i=1, NUM_SLOTS, 1 do which the other 2 do not ...
You don't. There is literally no difference whatsoever between "for i = 1, 10 do" and "for i = 1, 10, 1 do".

Also:

While it doesn't really matter, you should use variable names that make sense. A variable like "buttonName" should logically contain the name of a button, not the button object itself.

Rather than doing more string concatenations and global lookups )eg. _["ThisBarButton"..i.."Icon"]) you should use the keys on the button that already point to those things (eg. button.icon).

Don't forget to call ClearAllPoints before you start calling SetPoint -- otherwise you may end up with unexpected results if the original region was positioned with points other than the ones you're setting.

Avoid duplicating code. If you're going to use the same chunk of code in 5 different places, factor it out into a function, and just call the function from those 5 places.

http://pastebin.com/WEGEz70y
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
04-30-14, 10:31 PM   #48
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Phanx View Post
You don't. There is literally no difference whatsoever between "for i = 1, 10 do" and "for i = 1, 10, 1 do".

Also:

While it doesn't really matter, you should use variable names that make sense. A variable like "buttonName" should logically contain the name of a button, not the button object itself.

Rather than doing more string concatenations and global lookups )eg. _["ThisBarButton"..i.."Icon"]) you should use the keys on the button that already point to those things (eg. button.icon).

Don't forget to call ClearAllPoints before you start calling SetPoint -- otherwise you may end up with unexpected results if the original region was positioned with points other than the ones you're setting.

Avoid duplicating code. If you're going to use the same chunk of code in 5 different places, factor it out into a function, and just call the function from those 5 places.

http://pastebin.com/WEGEz70y
Your code works perfect like normal.

Thank You
Coke
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Addon_action_blocked

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off