# HG changeset patch # User Vynn # Date 1478798741 18000 # Node ID 761d71cd89893d897e2673da66fae66aecf9e3ec # Parent 31cf112106350b02c7b3eec9781127d8024dde6d Migration support for v1 to v2 transition diff -r 31cf11210635 -r 761d71cd8989 ProspectMe_Migrate.lua --- /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