changeset 64:e92a5adf75bf

Added first public API.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Tue, 27 Jul 2010 18:00:00 -0700
parents e7d287cc3b02
children 32d53abee666
files CHANGELOG.txt ItemAuditor.toc Modules/Api.lua Modules/Crafting.lua Modules/DisplayInvested.lua Modules/QuickAuctions.lua
diffstat 6 files changed, 38 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG.txt	Tue Jul 27 17:58:33 2010 -0700
+++ b/CHANGELOG.txt	Tue Jul 27 18:00:00 2010 -0700
@@ -2,6 +2,7 @@
 
 - Fixed an infinite loop when when adding items to the Skillet queue from the crafting interface.
 - For Developers: Changed ItemAuditor to no longer be in the global namespace
+- For Developers: Added IAapi to the public namespace so other addons can interact with ItemAuditor.
 
 2010-07-25  Asa Ayers  <Asa.Ayers@Gmail.com>
 
--- a/ItemAuditor.toc	Tue Jul 27 17:58:33 2010 -0700
+++ b/ItemAuditor.toc	Tue Jul 27 18:00:00 2010 -0700
@@ -24,3 +24,5 @@
 Modules\Crafting.lua
 
 Modules\QuickAuctions.lua
+
+Modules\Api.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Modules/Api.lua	Tue Jul 27 18:00:00 2010 -0700
@@ -0,0 +1,30 @@
+local ItemAuditor = select(2, ...)
+
+local Crafting = ItemAuditor:GetModule("Crafting")
+
+IAapi = {}
+
+--[[
+	You can register a callback here to influence which items will get crafted and how many.
+	The decider function needs to return the number of items the user should have in their
+	inventory. If the number owned is less than the highest decided number, that item will
+	be queued to be crafted unless any decider vetos the item.
+	
+	There is no way to unregister your decider but it can be overwritten with a function that simply returns 0.
+	
+	Please make sure your decider runs as fast as possible, It will be called at least once
+	for every tradeskill being considered.
+	
+	I find the (non) word "Decider" to be amusing, so I used it.
+	
+	ItemAuditor will veto any item that costs more to create than it will sell for, It will also
+	queue one of every item that is profitable. If you simply wanted to increase that to 5 of every
+	profitable item you could use this:
+	
+	IAapi.RegisterCraftingDecider('Five', function() return 5 end)
+]]
+function IAapi.RegisterCraftingDecider(name, decider)
+	Crafting.RegisterCraftingDecider(name, decider)
+end
+
+
--- a/Modules/Crafting.lua	Tue Jul 27 17:58:33 2010 -0700
+++ b/Modules/Crafting.lua	Tue Jul 27 18:00:00 2010 -0700
@@ -167,7 +167,7 @@
 
 local craftingDeciders = {}
 
-function ItemAuditor:RegisterCraftingDecider(name, decider)
+function Crafting.RegisterCraftingDecider(name, decider)
 	craftingDeciders[name] = decider
 end
 
@@ -200,7 +200,7 @@
 	end
 	return -1
 end
-ItemAuditor:RegisterCraftingDecider('Is Profitable', isProfitable)
+Crafting.RegisterCraftingDecider('Is Profitable', isProfitable)
 
 local function tableFilter(self, row, ...)
 	-- column 5 is how many should be crafted
--- a/Modules/DisplayInvested.lua	Tue Jul 27 17:58:33 2010 -0700
+++ b/Modules/DisplayInvested.lua	Tue Jul 27 18:00:00 2010 -0700
@@ -1,6 +1,7 @@
 local ItemAuditor = select(2, ...)
 local DisplayInvested = ItemAuditor:NewModule("DisplayInvested")
 
+
 local AceGUI = LibStub("AceGUI-3.0")
 local ScrollingTable = LibStub("ScrollingTable")
 
--- a/Modules/QuickAuctions.lua	Tue Jul 27 17:58:33 2010 -0700
+++ b/Modules/QuickAuctions.lua	Tue Jul 27 18:00:00 2010 -0700
@@ -1,5 +1,6 @@
 local ItemAuditor = select(2, ...)
 local QuickAuctions= ItemAuditor:NewModule("QuickAuctions")
+local Crafting = ItemAuditor:GetModule("Crafting")
 
 --[[
 	This is simply for compatibility while I change the QA API. Once
@@ -113,7 +114,7 @@
 	end
 	return 0
 end
-ItemAuditor:RegisterCraftingDecider('IA QuickAuctions', isProfitable)
+Crafting.RegisterCraftingDecider('IA QuickAuctions', isProfitable)
 
 --[[
 	This is based on KTQ