Mercurial > wow > itemauditor
changeset 69:4ae431c98059
Added integration with ArkInventory. You can set up rules that use "itemauditor('profitable')" or "itemauditor('qa')" to find items managed by QuickAuctions
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Wed, 28 Jul 2010 21:27:39 -0700 |
parents | 2d65db19d3ce |
children | 3930518cb8d9 |
files | CHANGELOG.txt ItemAuditor.toc Modules/ArkInventoryRules.lua Modules/UnitTests.lua |
diffstat | 4 files changed, 83 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG.txt Wed Jul 28 11:37:43 2010 -0700 +++ b/CHANGELOG.txt Wed Jul 28 21:27:39 2010 -0700 @@ -2,6 +2,7 @@ - Fixed a bug with the crafting threshold options. - Updated /ia queue so that it is a shortcut to using /ia crafting and then clicking export. +- Added integration with ArkInventory. You can set up rules that use "itemauditor('profitable')" or "itemauditor('qa')" to find items managed by QuickAuctions. 2010-07-27 Asa Ayers <Asa.Ayers@Gmail.com>
--- a/ItemAuditor.toc Wed Jul 28 11:37:43 2010 -0700 +++ b/ItemAuditor.toc Wed Jul 28 21:27:39 2010 -0700 @@ -18,13 +18,12 @@ Modules\Frames.lua Modules\Events.lua Modules\Tooltip.lua - Modules\Debug.lua Modules\DisplayInvested.lua Modules\Crafting.lua - Modules\QuickAuctions.lua - Modules\Api.lua +Modules\ArkInventoryRules.lua Modules\UnitTests.lua +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/ArkInventoryRules.lua Wed Jul 28 21:27:39 2010 -0700 @@ -0,0 +1,79 @@ +if not ArkInventoryRules then + return +end + +local ItemAuditor = select(2, ...) +local ArkInventory = ItemAuditor:NewModule("ArkInventory") + +function ArkInventory:OnEnable( ) + ItemAuditor:Print('Registering with ArkInventory') + ArkInventoryRules.Register(self, "itemauditor", ArkInventory.Execute) +end + +function ArkInventory.Execute( ... ) + + -- always check for the hyperlink and that it's an actual item, not a spell (pet/mount) + if not ArkInventoryRules.Item.h or ArkInventoryRules.Item.class ~= "item" then + return false + end + + local fn = "test" -- your rule name, needs to be set so that error messages are readable + + local ac = select( '#', ... ) + + -- if you need at least 1 argument, this is how you check, if you dont need or care then you can remove this part + if ac == 0 then + error( string.format( ArkInventory.Localise["RULE_FAILED_ARGUMENT_NONE_SPECIFIED"], fn ), 0 ) + end + + for ax = 1, ac do -- loop through the supplied ... arguments + + local arg = select( ax, ... ) -- select the argument were going to work with + + -- this code checks item quality, either as text or as a number + -- your best bet is to check the existing system rules to find one thats close to what you need an modify it to suit your needs + -- all you have to do is ensure that you return true (matched your criteria) or false (failed to match) + + if type( arg ) == "string" then + local link = ArkInventoryRules.Item.h + + local itemName = GetItemInfo(link) + + if string.lower( strtrim( arg ) ) == 'profitable' then + + local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link) + + if investedTotal > 0 then + local ap = ItemAuditor:GetAuctionPrice(link) + local keep = 1 - ItemAuditor:GetAHCut() + + if ap ~= nil then + + if ap > ceil(investedPerItem/keep) then + return true + end + end + end + return false + elseif string.lower( strtrim( arg ) ) == 'qa' then + if ItemAuditor:IsQAEnabled() then + local groupName = QAAPI:GetItemGroup(link) + if groupName then + return true + end + end + return false + end + + else + + error( string.format( ArkInventory.Localise["RULE_FAILED_ARGUMENT_IS_INVALID"], fn, ax, string.format( "%s or %s", ArkInventory.Localise["STRING"], ArkInventory.Localise["NUMBER"] ) ), 0 ) + + end + + end + + return false + +end +
--- a/Modules/UnitTests.lua Wed Jul 28 11:37:43 2010 -0700 +++ b/Modules/UnitTests.lua Wed Jul 28 21:27:39 2010 -0700 @@ -208,6 +208,6 @@ if WoWUnit then WoWUnit:AddTestSuite("ItemAuditor", UnitTests); - WoWUnitConsole:SlashCommand('ItemAuditor') + -- WoWUnitConsole:SlashCommand('ItemAuditor') end --@end-debug@ \ No newline at end of file