Mercurial > wow > itemauditor
comparison Modules/Utils.lua @ 7:bbba2fae0f69
Removed some of the extra debugging that isn't neccessary any more and abtracted out the item ids so they can be cached.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Tue, 08 Jun 2010 11:19:16 -0700 |
parents | 5dddd73b2220 |
children | 0271e781b154 |
comparison
equal
deleted
inserted
replaced
6:5dddd73b2220 | 7:bbba2fae0f69 |
---|---|
10 local prefix = "" | 10 local prefix = "" |
11 if money < 0 then | 11 if money < 0 then |
12 prefix = "-" | 12 prefix = "-" |
13 end | 13 end |
14 return prefix .. Altoholic:GetMoneyString(abs(money), WHITE, false) | 14 return prefix .. Altoholic:GetMoneyString(abs(money), WHITE, false) |
15 end | |
16 | |
17 -- This is only here to make sure this doesn't blow up if ReplaceItemCache is never called | |
18 local item_db = {} | |
19 | |
20 function addon:ReplaceItemCache(new_cache) | |
21 item_db = new_cache | |
22 end | |
23 | |
24 -- This will be reset every session | |
25 local tmp_item_cache = {} | |
26 function addon:GetItemID(itemName) | |
27 if item_db[itemName] ~= nil then | |
28 return item_db[itemName] | |
29 end | |
30 | |
31 if tmp_item_cache[itemName] == nil then | |
32 local _, itemLink = GetItemInfo (itemName); | |
33 if itemLink ~= nil then | |
34 local _, _, _, _, itemID = string.find(itemLink, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?") | |
35 tmp_item_cache[itemName] = tonumber(itemID) | |
36 end | |
37 end | |
38 | |
39 return tmp_item_cache[itemName] | |
40 end | |
41 | |
42 function addon:SaveItemID(itemName, id) | |
43 item_db[itemName] = tonumber(id) | |
15 end | 44 end |
16 | 45 |
17 local SubjectPatterns = { | 46 local SubjectPatterns = { |
18 AHCancelled = gsub(AUCTION_REMOVED_MAIL_SUBJECT, "%%s", ".*"), | 47 AHCancelled = gsub(AUCTION_REMOVED_MAIL_SUBJECT, "%%s", ".*"), |
19 AHExpired = gsub(AUCTION_EXPIRED_MAIL_SUBJECT, "%%s", ".*"), | 48 AHExpired = gsub(AUCTION_EXPIRED_MAIL_SUBJECT, "%%s", ".*"), |