Asa@74: Asa@69: Asa@69: local ItemAuditor = select(2, ...) Asa@69: local ArkInventory = ItemAuditor:NewModule("ArkInventory") Asa@69: Asa@69: function ArkInventory:OnEnable( ) Asa@74: if ArkInventoryRules then Asa@74: ItemAuditor:Print('Registering with ArkInventory') Asa@74: ArkInventoryRules.Register(self, "itemauditor", ArkInventory.Execute) Asa@74: end Asa@69: end Asa@69: Asa@69: function ArkInventory.Execute( ... ) Asa@69: Asa@69: -- always check for the hyperlink and that it's an actual item, not a spell (pet/mount) Asa@69: if not ArkInventoryRules.Item.h or ArkInventoryRules.Item.class ~= "item" then Asa@69: return false Asa@69: end Asa@69: Asa@69: local fn = "test" -- your rule name, needs to be set so that error messages are readable Asa@69: Asa@69: local ac = select( '#', ... ) Asa@69: Asa@69: -- if you need at least 1 argument, this is how you check, if you dont need or care then you can remove this part Asa@69: if ac == 0 then Asa@69: error( string.format( ArkInventory.Localise["RULE_FAILED_ARGUMENT_NONE_SPECIFIED"], fn ), 0 ) Asa@69: end Asa@69: Asa@69: for ax = 1, ac do -- loop through the supplied ... arguments Asa@69: Asa@69: local arg = select( ax, ... ) -- select the argument were going to work with Asa@69: Asa@69: -- this code checks item quality, either as text or as a number Asa@69: -- 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 Asa@69: -- all you have to do is ensure that you return true (matched your criteria) or false (failed to match) Asa@69: Asa@69: if type( arg ) == "string" then Asa@69: local link = ArkInventoryRules.Item.h Asa@69: Asa@69: local itemName = GetItemInfo(link) Asa@69: Asa@69: if string.lower( strtrim( arg ) ) == 'profitable' then Asa@69: Asa@69: local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link) Asa@69: Asa@69: if investedTotal > 0 then Asa@69: local ap = ItemAuditor:GetAuctionPrice(link) Asa@69: local keep = 1 - ItemAuditor:GetAHCut() Asa@69: Asa@69: if ap ~= nil then Asa@69: Asa@69: if ap > ceil(investedPerItem/keep) then Asa@69: return true Asa@69: end Asa@69: end Asa@69: end Asa@69: return false Asa@69: elseif string.lower( strtrim( arg ) ) == 'qa' then Asa@69: if ItemAuditor:IsQAEnabled() then Asa@69: local groupName = QAAPI:GetItemGroup(link) Asa@69: if groupName then Asa@69: return true Asa@69: end Asa@69: end Asa@69: return false Asa@69: end Asa@69: Asa@69: else Asa@69: Asa@69: error( string.format( ArkInventory.Localise["RULE_FAILED_ARGUMENT_IS_INVALID"], fn, ax, string.format( "%s or %s", ArkInventory.Localise["STRING"], ArkInventory.Localise["NUMBER"] ) ), 0 ) Asa@69: Asa@69: end Asa@69: Asa@69: end Asa@69: Asa@69: return false Asa@69: Asa@69: end Asa@69: