changeset 95:63823b6b5e28

API: Added a way for other addons to register with ItemAuditor once it loads if they were loaded first and updated the example at the end of Api.lua.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Thu, 12 Aug 2010 00:54:00 -0700
parents 4ec8611d9466
children 1fbbe3b53f6e
files CHANGELOG.txt Modules/Api.lua Modules/Crafting.lua
diffstat 3 files changed, 33 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG.txt	Wed Aug 11 23:48:23 2010 -0700
+++ b/CHANGELOG.txt	Thu Aug 12 00:54:00 2010 -0700
@@ -7,6 +7,7 @@
 - Fixed Enchanting. I was not getting the ItemID correctly, so enchants could not be mapped to the scrolls they were to created
 - Changed snatch to only add each item once and to only add a snatch for items you don't have
 - API: Added haveMaterials to the item and need to the reagents that get passed to queue destinations. This is in preparation for building a shopping list module.
+- API: Added a way for other addons to register with ItemAuditor once it loads if they were loaded first and updated the example at the end of Api.lua.
 
 2010-08-10  Asa Ayers  <Asa.Ayers@Gmail.com>
 
--- a/Modules/Api.lua	Wed Aug 11 23:48:23 2010 -0700
+++ b/Modules/Api.lua	Thu Aug 12 00:54:00 2010 -0700
@@ -42,11 +42,38 @@
 	Crafting.UnRegisterQueueDestination(name)
 end
 
+local function registerLoadedAddons()
+	return ItemAuditor_RegisterAPI and ItemAuditor_RegisterAPI()
+end
+registerLoadedAddons()
+
+
+-- This is here so I have a second option in the menu and to serve as an example of
+-- how to register your addon with ItemAuditor.
 --@debug@
--- This is here so I have a second option in the menu and to serve as an example.
-local function testDestination(data)
-	ItemAuditor:Print('queue: '..data.recipeLink)
+local function RegisterWithItemAuditor()
+	local function testDestination(data)
+		-- Replace this with a call to the methods you need in your addon
+		ItemAuditor:Print('queue: '..data.recipeLink)
+	end
+	-- Replace Echo with the name of your addon so it can be selected from /ia options
+	IAapi.RegisterQueueDestination('Echo', testDestination)
 end
 
-IAapi.RegisterQueueDestination('Echo', testDestination)
+if IAapi then
+	RegisterWithItemAuditor()
+else
+	-- make sure to save any other addon's function
+	local original = ItemAuditor_RegisterAPI
+	-- this should not be local so it replaces (or creates) the global function
+	function ItemAuditor_RegisterAPI()
+		RegisterWithItemAuditor()
+		-- if original has a value (function), this will run it
+		return original and original()
+	end
+end
+
+
+
+
 --@end-debug@
--- a/Modules/Crafting.lua	Wed Aug 11 23:48:23 2010 -0700
+++ b/Modules/Crafting.lua	Thu Aug 12 00:54:00 2010 -0700
@@ -396,6 +396,7 @@
 				end
 				local data = {
 					recipeLink = recipeLink,
+					recipeID = Utils.GetItemID(recipeLink),
 					link = itemLink,
 					name = itemName,
 					count = count,