changeset 34:761d71cd8989 Prospect Me 2

Migration support for v1 to v2 transition
author Vynn <mischivin@gmail.com>
date Thu, 10 Nov 2016 12:25:41 -0500
parents 31cf11210635
children 705d0595006a
files ProspectMe_Migrate.lua
diffstat 1 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ProspectMe_Migrate.lua	Thu Nov 10 12:25:41 2016 -0500
@@ -0,0 +1,41 @@
+local ORE = select(7,GetItemInfo(123918))
+local HERB = select(7,GetItemInfo(128304))
+
+local function Initialize ()
+	ProspectMe.Migrate = function ()
+		print("Attempting to migrate ProspectMe database")
+		if PM_ResultsTable then
+			print("|cffffff00ProspectMe v1 database found|r")
+			for Container, Item in pairs(PM_ResultsTable) do
+				local C = tonumber(Container)
+				local B = nil
+				local RT = {}
+				for Result, Quantity in pairs (Item) do
+					if Result == "timesProspected" then
+						B = Quantity
+					else 
+						RT[tonumber(Result)] = Quantity
+					end
+				end
+				if select(7,GetItemInfo(C)) == ORE or select(7,GetItemInfo(C)) == HERB then
+					ProspectMe.AddEntry(C, B, RT)
+				end
+			end
+			print("|cff00ff00Database migrated sucessfully!|r")
+			PM_ResultsTable = nil
+			PM_ItemTable = nil
+			PM_Config = nil
+		else
+			print("|cffff0000Error, ProspectMe v1 database not found|r")
+		end
+	end
+
+	if PM_ResultsTable then
+		print("ProspectMe v1 database found, to migrate your database to v2 run the command |cff00ff00/script ProspectMe.Migrate()|r \n |cffff0000Warning, this action is irreversable!|r")
+	end
+end
+
+local frame = CreateFrame("FRAME", "ProspectMe_Value")
+frame:RegisterEvent("VARIABLES_LOADED")
+--frame:SetScript("OnEvent", EventHandler)
+frame:SetScript("OnEvent", Initialize)
\ No newline at end of file