changeset 21:dc011841fcb4

Added handling of remenant Gem Chips on load - this should clean up and consolidate any lingering chips from 1.7.0.2
author Geoff Brock <mischivin@gmail.com>
date Sun, 04 Sep 2016 21:53:29 -0400
parents 4a10e5d1618c
children ddf9b42996da
files ProspectMe.lua
diffstat 1 files changed, 32 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ProspectMe.lua	Sun Sep 04 21:51:07 2016 -0400
+++ b/ProspectMe.lua	Sun Sep 04 21:53:29 2016 -0400
@@ -12,14 +12,6 @@
 local getContents = false
 local bulkMultiplier = 1 --This will be used for mass prospecting/milling in Legion
 
-local function PM_Init()
-	if not PM_ResultsTable then
-		PM_ResultsTable = {}
-		PM_ItemTable = {}
-	end
-	PM_SessionTable = {}
-end
-
 local function CreateTableEntry(id)
 	local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(id)
 	PM_ItemTable[id] = {}
@@ -37,6 +29,38 @@
 	PM_ItemTable[id].price = PM_GetItemValue(id)
 end
 
+function PM_GemCleanup()
+	local cleanupIDs = { "129099", "130200", "130201", "130202", "130203", "130204" }
+	if not PM_ItemTable["129100"] then
+		CreateTableEntry("129100")
+	end
+	for i, r in pairs(PM_ResultsTable) do
+		for k, v in pairs(cleanupIDs) do 
+			if PM_ResultsTable[i][v] then 
+				if not PM_ResultsTable[i]["129100"] then
+					PM_ResultsTable[i]["129100"] = 0
+				end
+				PM_ResultsTable[i]["129100"] = PM_ResultsTable[i]["129100"] + PM_ResultsTable[i][v]
+				PM_ResultsTable[i][v] = nil
+			end
+		end
+	end
+	for k, v in pairs(cleanupIDs) do
+		if PM_ItemTable[v] then
+			PM_ItemTable[v] = nil
+		end
+	end
+end
+
+local function PM_Init()
+	if not PM_ResultsTable then
+		PM_ResultsTable = {}
+		PM_ItemTable = {}
+	end
+	PM_SessionTable = {}
+	PM_GemCleanup() --Run cleanup on excess Gem Chips created in v1.7.0.2 and earlier
+end
+
 --debugging function to print the databases results
 function PM_PrintResults()
 	for container, k in pairs(PM_ResultsTable) do