diff 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
line wrap: on
line diff
--- a/ProspectMe_Value.lua	Thu Oct 27 12:51:54 2016 -0400
+++ b/ProspectMe_Value.lua	Thu Nov 17 16:24:48 2016 -0500
@@ -1,30 +1,26 @@
-function PM_GetItemValue(itemID)
-	local v = nil
-	if GetAuctionBuyout then -- if an installed addon supports Tekkub's GetAuctionBuyout API: Auctionator, AuctionLite, etc...
-		v = GetAuctionBuyout(itemID)
+local function Initialize ()
+	ProspectMe.GetItemValue = function (itemID)
+		local v = nil
+		
+		if GetAuctionBuyout then -- if an installed addon supports Tekkub's GetAuctionBuyout API: Auctionator, AuctionLite, etc...
+			v = GetAuctionBuyout(itemID)
+		elseif AucAdvanced then -- Auctioneer Support
+			v = AucAdvanced.API.GetMarketValue(PM_ItemTable[itemID].link)
+		end
+		
+		if v == nil then -- provides a failsafe if Auctioneer, etc is set to Load on Demand
+			v = select(11, GetItemInfo(itemID))
+		end
+		
+		if v == nil then -- provides a final failsafe - if we can't find anything, set it to 0 (TY peterwemm!)
+			v = 0.0
+		end
+
+		return tonumber(v)
 	end
-	
-	if v == nil then
-		if AucAdvanced then -- Auctioneer Support
-			v = AucAdvanced.API.GetMarketValue(PM_ItemTable[itemID].link)
-		else -- if nothing else, use the vendor price!
-			v = PM_ItemTable[itemID].vendorPrice
-		end
-	end
-	
-	if v == nil then -- provides a failsafe if Auctioneer, etc is set to Load on Demand
-		v = PM_ItemTable[itemID].vendorPrice
-	end
-	
-	if v == nil then -- provides a final failsafe - if we can't find anything, set it to 0 (TY peterwemm!)
-		v = 0.0
-	end
-
-	return tonumber(v)
 end
 
-function PM_UpdateValues()
-	for k,v in pairs(PM_ItemTable) do
-		PM_ItemTable[k].price = PM_GetItemValue(k)
-	end
-end
\ No newline at end of file
+local frame = CreateFrame("FRAME", "ProspectMe_Value")
+frame:RegisterEvent("VARIABLES_LOADED")
+--frame:SetScript("OnEvent", EventHandler)
+frame:SetScript("OnEvent", Initialize)
\ No newline at end of file