comparison ProspectMe_Value.lua @ 49:9dae86337a41

Merge Prospect Me v2 Branch to default
author Vynn <mischivin@gmail.com>
date Thu, 17 Nov 2016 16:24:48 -0500
parents 5cbaaee1e7db
children
comparison
equal deleted inserted replaced
28:dc1504b4c03c 49:9dae86337a41
1 function PM_GetItemValue(itemID) 1 local function Initialize ()
2 local v = nil 2 ProspectMe.GetItemValue = function (itemID)
3 if GetAuctionBuyout then -- if an installed addon supports Tekkub's GetAuctionBuyout API: Auctionator, AuctionLite, etc... 3 local v = nil
4 v = GetAuctionBuyout(itemID) 4
5 if GetAuctionBuyout then -- if an installed addon supports Tekkub's GetAuctionBuyout API: Auctionator, AuctionLite, etc...
6 v = GetAuctionBuyout(itemID)
7 elseif AucAdvanced then -- Auctioneer Support
8 v = AucAdvanced.API.GetMarketValue(PM_ItemTable[itemID].link)
9 end
10
11 if v == nil then -- provides a failsafe if Auctioneer, etc is set to Load on Demand
12 v = select(11, GetItemInfo(itemID))
13 end
14
15 if v == nil then -- provides a final failsafe - if we can't find anything, set it to 0 (TY peterwemm!)
16 v = 0.0
17 end
18
19 return tonumber(v)
5 end 20 end
6
7 if v == nil then
8 if AucAdvanced then -- Auctioneer Support
9 v = AucAdvanced.API.GetMarketValue(PM_ItemTable[itemID].link)
10 else -- if nothing else, use the vendor price!
11 v = PM_ItemTable[itemID].vendorPrice
12 end
13 end
14
15 if v == nil then -- provides a failsafe if Auctioneer, etc is set to Load on Demand
16 v = PM_ItemTable[itemID].vendorPrice
17 end
18
19 if v == nil then -- provides a final failsafe - if we can't find anything, set it to 0 (TY peterwemm!)
20 v = 0.0
21 end
22
23 return tonumber(v)
24 end 21 end
25 22
26 function PM_UpdateValues() 23 local frame = CreateFrame("FRAME", "ProspectMe_Value")
27 for k,v in pairs(PM_ItemTable) do 24 frame:RegisterEvent("VARIABLES_LOADED")
28 PM_ItemTable[k].price = PM_GetItemValue(k) 25 --frame:SetScript("OnEvent", EventHandler)
29 end 26 frame:SetScript("OnEvent", Initialize)
30 end