Thread Tools Display Modes
02-27-12, 03:04 AM   #1
Lilbitters
A Defias Bandit
AddOn Compiler - Click to view compilations
Join Date: Aug 2010
Posts: 2
InternalCooldowns

I previously used an addon to track internal cooldowns named InternalCooldowns (http://www.wowace.com/addons/internal-cooldowns/) which doesn't have a module for Dominos (only Bartender4).

I have the addon updated properly for all Tier12 and Tier13 trinket/weapon/set procs from altering the Data.lua in LibInternalCooldowns-1.0, so that isn't an issue, as the addon works properly on the character sheet (via the PaperDollFrame.lua).

I was wondering if anyone knew of a way to update this addon (most likely through creating a module for Dominos) so that it would display internal cooldowns on action bars also (like if you had a trinket on your action bar, when it proc'd, the ICD would be displayed there too, like it is on the character sheet).


And example of the modlue Antiarc used for Bartender4 is:
Code:
local mod = LibStub("AceAddon-3.0"):GetAddon("InternalCooldowns"):NewModule("Bartender4", "AceEvent-3.0")
local lib = LibStub("LibInternalCooldowns-1.0")
if not _G.Bartender4 then return end

function mod:OnEnable()
	lib.RegisterCallback(self, "InternalCooldowns_Proc")
end

function mod:OnDisable()
	lib.UnregisterCallback(self, "InternalCooldowns_Proc")
end

function mod:InternalCooldowns_Proc()
	for i = 1, 120 do
		local f = _G["BT4Button" .. i]
		if f and f:IsVisible() then
			ActionButton_UpdateCooldown(f)
		end
	end	
end
I tried modifying it to:
Code:
local mod = LibStub("AceAddon-3.0"):GetAddon("InternalCooldowns"):NewModule("Dominos", "AceEvent-3.0")
local lib = LibStub("LibInternalCooldowns-1.0")
if not _G.Dominos then return end

function mod:OnEnable()
	lib.RegisterCallback(self, "InternalCooldowns_Proc")
end

function mod:OnDisable()
	lib.UnregisterCallback(self, "InternalCooldowns_Proc")
end

function mod:InternalCooldowns_Proc()
	for i = 1, 120 do
		local f = _G["ActionButton", "DominosActionButton", "MultiBarRightButton", "MultiBarLeftButton", "MultiBarBottomRightButton", "MultiBarBottomLeftButton", "DominosActionButton", "DominosActionButton", "DominosActionButton", "DominosActionButton", "PetActionButton" .. i]
		if f and f:IsVisible() then
			ActionButton_UpdateCooldown(f)
		end
	end	
end
However, this attempt is just causing an error from attempting to call a protected function:
Code:
Message: Note: AddOn InternalCooldowns attempted to call a protected function (ActionButton2:Show()) during combat lockdown.
Debug:
   [C]: Show()
   ..\FrameXML\ActionButton.lua:246:
      ..\FrameXML\ActionButton.lua:231
   [C]: ActionButton_Update()
   ..\FrameXML\ActionButton.lua:484: ActionButton_OnEvent()
   ..\FrameXML\ActionButton.lua:105:
      ..\FrameXML\ActionButton.lua:98

Thank you in advance if you can figure out any way to get this working!
(And thank you for the advice/suggestion, but I know of similar addons that track ICDs via bars like Heatsink or NeedToKnow, but that isn't what I'm looking for as an alternative.)
  Reply With Quote
02-27-12, 03:27 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, I'm not sure why you got that particular error. You should have been getting 120 errors every time an internal cooldown procs, from this line:

Code:
		local f = _G["ActionButton", "DominosActionButton", "MultiBarRightButton", "MultiBarLeftButton", "MultiBarBottomRightButton", "MultiBarBottomLeftButton", "DominosActionButton", "DominosActionButton", "DominosActionButton", "DominosActionButton", "PetActionButton" .. i]
In the original code, local f = _G["ActionButton"..i] does these things:
  1. First, it concatenates the string "ActionButton"..i. For example, in the first iteration of the loop, the final string is "ActionButton1", while on the 75th iteration of the loop, it is "ActionButton75", since the variable i contains the number 1 in the first iteration, and increments upward by 1 each time the loop repeats.
  2. Then, it gets the table that the variable _G points to. In this case, this table is the global namespace.
  3. Then, it looks inside that table to find the key whose name is the string "ActionButton1" or "ActionButton75", depending on which iteration of the loop we're inside.
  4. Finally, it gets the value attached to that key, and assigns it to the variable named f.
In your code, you create a list of strings, only the last one of which attempts any concatenation. Not only will this fail in step #3, since there is no key in the global namespace whose name is that list of strings, but it should also trigger a Lua error immediately because a list of strings inside a table lookup (square brackets) is not valid Lua syntax. A list of strings is only allowed inside a table:

Code:
local t = { "Apple", "Banana", "Coconut" }
... or as part of a variable assignment statement:

Code:
local a, b, c = "Apple", "Banana", "Coconut"
You should have gotten an error message saying something like:

Code:
']' expected near ','
I'm not familiar with the inner workings of Dominos, but I believe it just reuses the Blizzard action button objects, so this should work, and it is at least valid Lua syntax:

Code:
function mod:InternalCooldowns_Proc()
	for i = 1, 120 do
		local f = _G["ActionButton"..i]
		if f and f:IsVisible() then
			ActionButton_UpdateCooldown(f)
		end
	end
end
If you want to also affect other buttons, such as the multi-cast action buttons, you need to add another for i = 1, N do ... end loop, where N is the number of buttons that exist in that group.
  Reply With Quote
02-27-12, 05:26 PM   #3
Lilbitters
A Defias Bandit
AddOn Compiler - Click to view compilations
Join Date: Aug 2010
Posts: 2
Thanks for the help Phanx, but I was apparently headed in the wrong direction from the start, as something else in the code of the Core.lua must be what's causing the error (and yes, it actually is 144 errors total once I enter combat). I actually had tried the code that you suggested before and was still having the same error so I thought I was doing something wrong there, but alas, that was not the problem anyway.

I disabled Dominos and tried taking out all of the other modules but it still was causing the same error when I'm in combat. Outside of combat, the addon is actually triggering the display of the ICD when I get a buff proc, but then instantly disappears. I can the ICD display to reappear by removing the trinket from the action bar and just putting it back on the action bar, but again the next buff proc removes the it.

I really don't know much at all about .lua coding, only what I can piece together from looking at things and what I can learn from others so the help is greatly appreciated!

Core.lua code from InternalCooldowns:
Code:
local mod = LibStub("AceAddon-3.0"):NewAddon("InternalCooldowns")

local options = {
	type = "group",
	args = {}
}

local optionFrames = {}
local ACD3 = LibStub("AceConfigDialog-3.0")

function mod:OnInitialize()
	self.options = options
	self.db = LibStub("AceDB-3.0"):New("InternalCooldownsDB", defaults)
	LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("InternalCooldowns", options)
	ACD3:AddToBlizOptions("InternalCooldowns")
end

function mod:RegisterModuleOptions(name, optionTbl, displayName)
	do return end
	options.args[name] = (type(optionTbl) == "function") and optionTbl() or optionTbl
	if not optionFrames.default then
		optionFrames.default = ACD3:AddToBlizOptions("InternalCooldowns", nil, nil, name)
	else
		optionFrames[name] = ACD3:AddToBlizOptions("InternalCooldowns", displayName, "InternalCooldowns", name)
	end
end
PaperDollFrame.lua module which is working properly:
Code:
local mod = LibStub("AceAddon-3.0"):GetAddon("InternalCooldowns"):NewModule("PaperDollFrame", "AceEvent-3.0")
local lib = LibStub("LibInternalCooldowns-1.0")

local slots = {
	[0] = "CharacterAmmoSlot",
	[1] = "CharacterHeadSlot",
	[2] = "CharacterNeckSlot",
	[3] = "CharacterShoulderSlot",
	[4] = "CharacterShirtSlot",
	[5] = "CharacterChestSlot",
	[6] = "CharacterWaistSlot",
	[7] = "CharacterLegsSlot",
	[8] = "CharacterFeetSlot",
	[9] = "CharacterWristSlot",
	[10]= "CharacterHandsSlot",
	[11]= "CharacterFinger0Slot",
	[12]= "CharacterFinger1Slot",
	[13]= "CharacterTrinket0Slot",
	[14]= "CharacterTrinket1Slot",
	[15]= "CharacterBackSlot",
	[16]= "CharacterMainHandSlot",
	[17]= "CharacterSecondaryHandSlot",
	[18]= "CharacterRangedSlot",
	[19]= "CharacterTabardSlot"
}

local equippedItems = {}

function mod:OnEnable()
	self:RegisterEvent("UNIT_INVENTORY_CHANGED")
	self:UNIT_INVENTORY_CHANGED("player")
	lib.RegisterCallback(mod, "InternalCooldowns_Proc")	
end

function mod:OnDisable()
	self:UnregisterEvent("UNIT_INVENTORY_CHANGED")
	lib.UnregisterCallback(mod, "InternalCooldowns_Proc")
end

function mod:UNIT_INVENTORY_CHANGED(unit)
	if unit == "player" then
		wipe(equippedItems)
		for i = 1, 19 do
			local link = GetInventoryItemLink(unit, i)
			if link then
				equippedItems[tonumber(link:match("item:(%d+)") or 0)] = i
			end			
		end
	end
end

function mod:InternalCooldowns_Proc(callback, itemID, spellID, start, duration)
	local slot = equippedItems[itemID]
	if slot then
		_G[slots[slot] .. "Cooldown"]:SetCooldown(start, duration)
	end
end
I'm assuming the outdated code will just be too much to get this addon from working properly (perhaps that's why there are no others like it) so I may just have to give up on this endeavor and switch to a bar style ICD display.

Last edited by Lilbitters : 02-27-12 at 05:33 PM.
  Reply With Quote
02-27-12, 09:16 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, I know LibInternalCooldowns caused a lot of taint that broke some things (mainly MultiCastActionButton1-n) back when I used it, and it didn't seem like it was being actively maintained, so switched to a different cooldown tracking addon.

What you want to do is definitely possible. I just don't know of any addons that do it without using LibInternalCooldowns.

However, if LibInternalCooldowns itself does not break anything in your setup, and you're willing to do some Lua editing, you might try modifying Inline Aura to highlight buttons based on LibInternalCooldown callbacks instead of buff/debuff events.
  Reply With Quote
03-24-13, 05:21 AM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Phanx View Post
Well, I know LibInternalCooldowns caused a lot of taint that broke some things (mainly MultiCastActionButton1-n) back when I used it, and it didn't seem like it was being actively maintained, so switched to a different cooldown tracking addon.

What you want to do is definitely possible. I just don't know of any addons that do it without using LibInternalCooldowns.

However, if LibInternalCooldowns itself does not break anything in your setup, and you're willing to do some Lua editing, you might try modifying Inline Aura to highlight buttons based on LibInternalCooldown callbacks instead of buff/debuff events.
Since i really love the addon, i always maintaned InternalCooldowns for myself (Had to remove some functions to prevent taints.) I could also write a Dominos support for it later, here is a link for the 5.2 version:

<link removed>

Last edited by Haleth : 03-24-13 at 05:27 AM.
  Reply With Quote
03-24-13, 05:28 AM   #6
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Please don't link to offsite downloads You can post the code here or on a website like pastebin, or if there's a lot of files, host it somewhere reliable like GitHub so we can view it online. Thanks!
  Reply With Quote
03-24-13, 07:03 AM   #7
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Haleth View Post
Please don't link to offsite downloads You can post the code here or on a website like pastebin, or if there's a lot of files, host it somewhere reliable like GitHub so we can view it online. Thanks!
https://github.com/Resike/InternalCooldowns
  Reply With Quote
03-24-13, 11:16 AM   #8
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Haleth View Post
Please don't link to offsite downloads You can post the code here or on a website like pastebin, or if there's a lot of files, host it somewhere reliable like GitHub so we can view it online. Thanks!
WoWAce is generally considered fine here...
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
03-24-13, 01:58 PM   #9
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
The second link (the one I removed) was a Dropbox .zip link.
  Reply With Quote
03-24-13, 05:53 PM   #10
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Bah, missed that somehow. Sorry!
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
04-10-13, 10:24 PM   #11
xmrone
A Defias Bandit
Join Date: Dec 2012
Posts: 2
Originally Posted by Resike View Post
Since i really love the addon, i always maintaned InternalCooldowns for myself (Had to remove some functions to prevent taints.) I could also write a Dominos support for it later, here is a link for the 5.2 version:

<link removed>
For some reason the Bartender4 module doesn't work for me. No errors, cooldown just doesn't show up on bars. Works fine in the Paperdoll. Would greatly appreciate it if you could look into it.
  Reply With Quote
04-11-13, 03:53 AM   #12
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by xmrone View Post
For some reason the Bartender4 module doesn't work for me. No errors, cooldown just doesn't show up on bars. Works fine in the Paperdoll. Would greatly appreciate it if you could look into it.
Yeah, i will. Btw i use it with OmniCC and with a modified TrinketMenu for 5.2:

https://github.com/Resike/TrinketMenu
  Reply With Quote
04-15-13, 04:54 PM   #13
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by xmrone View Post
For some reason the Bartender4 module doesn't work for me. No errors, cooldown just doesn't show up on bars. Works fine in the Paperdoll. Would greatly appreciate it if you could look into it.
https://github.com/Resike/InternalCooldowns

Okay i managed to fix the Bartender4 support, and added Dominos support too, but there is 2 problem: The Dominos support is not woking correctly yet, if you move the trinket to different actionbuttons it's working. but it disappers when you use any actionbutton. The second problem randomly triggers a taint with: http://i.imgur.com/0N1XiZs.jpg. But this error only occours, if the actionbar addon is loaded also. I'm not sure its actually caused by InternalCooldowns or not, if anyone have an idea what causing this and how to fix it that would be awsome.
Anyway if you comment out 74th line in the "Libs/LibInternalCooldowns-1.0/LibInternalCooldowns-1.0.lua" then the error goes away, but also the actionbutton feature not gonna work.

Untill i can fix this error i think the best way to use the addon is with TrinketMenu and with the commented line i mentioned above: https://github.com/Resike/TrinketMenu
(I recently taken over this project i'm gonna make an update in wowinterface too soon: http://www.wowinterface.com/download...Menu.html#info)

Last edited by Resike : 04-15-13 at 04:57 PM.
  Reply With Quote
04-15-13, 07:42 PM   #14
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Resike View Post
... taint ... I'm not sure its actually caused by InternalCooldowns or not, if anyone have an idea what causing this and how to fix it that would be awsome.
This is (most likely) caused by LibInternalCooldowns insecurely hooking functions like GetActionCooldown that are used by secure code for action buttons. I'm assuming it was written so that addons using GetActionCooldown would automatically display internal cooldowns, and the default UI can handle it beacuse the default UI's "secure" frames aren't actually operating in the restricted environment, but secure frames created by addons are in the restricted environment, which can't handle taint like that. You'll have to use hooksecurefunc, in conjunction with a global function so it upgrades with your lib, eg:

Code:
if not LibInternalCooldowns_GetActionCooldown then
     -- Only apply the hook if this is the first instance of the lib to load.
     hooksecurefunc("GetActionCooldown", function(...) return LibInternalCooldowns_GetActionCooldown(...) end)
end

-- Overwrite any previous version of the global function.
LibInternalCooldowns_GetActionCooldown = function(...)
    -- do stuff here
end
See AceGUI-EditBox for a working example of an upgradable secure hook in a library. The above was typed from memory and may not be 100% accurate.

While this will solve that taint issue (there may be others; I stopped looking after that) it does mean that addons won't automatically get the cooldown info from the lib anymore, and you'll have to explicitly hook into each addon you want to support to feed it the info.

Also, there is no reason to ever use select in anything LibInternalCooldowns is doing. Stop wasting CPU time on useless extra function calls.
__________________
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-16-13, 03:18 AM   #15
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Phanx View Post
This is (most likely) caused by LibInternalCooldowns insecurely hooking functions like GetActionCooldown that are used by secure code for action buttons. I'm assuming it was written so that addons using GetActionCooldown would automatically display internal cooldowns, and the default UI can handle it beacuse the default UI's "secure" frames aren't actually operating in the restricted environment, but secure frames created by addons are in the restricted environment, which can't handle taint like that. You'll have to use hooksecurefunc, in conjunction with a global function so it upgrades with your lib, eg:

Code:
if not LibInternalCooldowns_GetActionCooldown then
     -- Only apply the hook if this is the first instance of the lib to load.
     hooksecurefunc("GetActionCooldown", function(...) return LibInternalCooldowns_GetActionCooldown(...) end)
end

-- Overwrite any previous version of the global function.
LibInternalCooldowns_GetActionCooldown = function(...)
    -- do stuff here
end
See AceGUI-EditBox for a working example of an upgradable secure hook in a library. The above was typed from memory and may not be 100% accurate.

While this will solve that taint issue (there may be others; I stopped looking after that) it does mean that addons won't automatically get the cooldown info from the lib anymore, and you'll have to explicitly hook into each addon you want to support to feed it the info.

Also, there is no reason to ever use select in anything LibInternalCooldowns is doing. Stop wasting CPU time on useless extra function calls.
And this securehook goona work with the default UI too, or it need to handle both differently? To be honest i'm really not familiar using libs, and i dont like them neither.

Okay, i'm here now:

https://gist.github.com/Resike/5394804

But what shoud the "LibInternalCooldowns_GetActionCooldown" return?

Last edited by Resike : 04-16-13 at 04:06 AM.
  Reply With Quote
04-16-13, 02:21 PM   #16
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Resike View Post
And this securehook goona work with the default UI too, or it need to handle both differently?
The difference is that the insecure hook would automatically feed internal cooldown data to all addons and the default UI, while hooksecurefunc will not -- it will only tell you when an addon or the default UI asked for cooldown info.

You will need to write additional code for every addon you want to support -- and for the default UI if you want to support it -- that finds out which button was asking for cooldown info and manually shows the addon's cooldown object with appropriate values.

Originally Posted by Resike View Post
But what shoud the "LibInternalCooldowns_GetActionCooldown" return?
It doesn't need to return anything. You're just using it to be notified when something asked for cooldown info. You will then need to figure out what was asking and update its cooldown object yourself.
__________________
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-16-13, 05:15 PM   #17
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Phanx View Post
The difference is that the insecure hook would automatically feed internal cooldown data to all addons and the default UI, while hooksecurefunc will not -- it will only tell you when an addon or the default UI asked for cooldown info.

You will need to write additional code for every addon you want to support -- and for the default UI if you want to support it -- that finds out which button was asking for cooldown info and manually shows the addon's cooldown object with appropriate values.



It doesn't need to return anything. You're just using it to be notified when something asked for cooldown info. You will then need to figure out what was asking and update its cooldown object yourself.
Okay, i don't think i can write that stuff. xD
Is there any way just to fix the taint, whilest keeping the currently working bartender4 support?

Last edited by Resike : 04-16-13 at 05:24 PM.
  Reply With Quote
04-18-13, 12:11 AM   #18
xmrone
A Defias Bandit
Join Date: Dec 2012
Posts: 2
Thanks for the update, works fine with Bartender4 now.
  Reply With Quote
04-18-13, 06:07 AM   #19
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by xmrone View Post
Thanks for the update, works fine with Bartender4 now.
Still, would be good to fix that taint error, tho if you don't have Bugsack you wont even notice it.
  Reply With Quote
04-18-13, 03:01 PM   #20
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
As long as those insecure hooks are in there, you're going to get taint errors when running any action bar addon. There's no way around it.
__________________
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

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » InternalCooldowns


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