more robustness fixes

git [02-16-18 - 07:35]
more robustness fixes
Filename
IIfA/IIfA.lua
IIfA/IIfADataCollection.lua
IIfA/IIfAMenu.lua
diff --git a/IIfA/IIfA.lua b/IIfA/IIfA.lua
index 9f1e363..e8545dd 100644
--- a/IIfA/IIfA.lua
+++ b/IIfA/IIfA.lua
@@ -487,6 +487,7 @@ function IIfA_onLoad(eventCode, addOnName)
 	if nil == IIfA.data[worldName].DBv3 then
 		 IIfA.data[worldName].DBv3 = IIfA.data.DBv3
 	end
+	IIfA.data.DBv3 = nil
 	IIfA.database = IIfA.data[worldName].DBv3

 	IIfA:ActionLayerInventoryUpdate()
@@ -501,18 +502,22 @@ function IIfA_onLoad(eventCode, addOnName)
 	IIfA.trackedBags[BAG_WORN] 		= not IIfA:IsCharacterEquipIgnored(IIfA.currentCharacterId)
 	IIfA.trackedBags[BAG_BACKPACK] 	= not IIfA:IsCharacterInventoryIgnored(IIfA.currentCharacterId)

+	IIfA:CollectAll()
+
+
+end
+
+EVENT_MANAGER:RegisterForEvent("IIfALoaded", EVENT_ADD_ON_LOADED, IIfA_onLoad)
+
+function IIfA:ScanCurrentCharacterAndBank()
+
 	IIfA:ScanBank()
 	IIfA:ScanCurrentCharacter()
 	zo_callLater(function()
 		IIfA:MakeBSI()
 	end, 5000)
-
-
-
 end

-EVENT_MANAGER:RegisterForEvent("IIfALoaded", EVENT_ADD_ON_LOADED, IIfA_onLoad)
-
 function IIfA:MakeBSI()
 	local bs = {}
 	local idx
diff --git a/IIfA/IIfADataCollection.lua b/IIfA/IIfADataCollection.lua
index 2b1e52b..cc69ac1 100644
--- a/IIfA/IIfADataCollection.lua
+++ b/IIfA/IIfADataCollection.lua
@@ -401,8 +401,17 @@ local function getLocation(location, bagId)
 	end
 end

+-- use getbsi to avoid "trying to access nil" errors
+function IIfA:GetBSI()
+	if nil == IIfA.BagSlotInfo then
+		IIfA:MakeBSI()
+	end
+	return IIfA.BagSlotInfo
+end
+
 function IIfA:SaveBagSlotIndex(bagId, slotId, itemLink)
 	if not bagId or not slotId then return end
+	IIfA.BagSlotInfo = IIfA.BagSlotInfo or {}
 	IIfA.BagSlotInfo[bagId] = IIfA.BagSlotInfo[bagId] or {}
 	IIfA.BagSlotInfo[bagId][slotId] = IIfA.BagSlotInfo[bagId][slotId] or itemLink
 end
@@ -581,6 +590,9 @@ function IIfA:CollectAll()

 	-- 6-3-17 AM - need to clear unowned items when deleting char/guildbank too
 	IIfA:ClearUnowned()
+	zo_callLater(function()
+		IIfA:MakeBSI()
+	end, 1000)
 end


diff --git a/IIfA/IIfAMenu.lua b/IIfA/IIfAMenu.lua
index 146b485..bc40005 100644
--- a/IIfA/IIfAMenu.lua
+++ b/IIfA/IIfAMenu.lua
@@ -98,6 +98,17 @@ function IIfA:CreateOptionsMenu()
 			name = "Manage Collected Data",
 			tooltip = "Manage collected Characters and Guild Banks. Delete data you no longer need (old guilds or deleted characters)",	--(optional)
 			controls = {
+				{  -- button begin
+					type = "button",
+					name = "Wipe database",
+					tooltip = "Deletes all collected data",
+					func = function()
+						local worldName 		= GetWorldName():gsub(" Megaserver", "")
+						IIfA.data[worldName] 	= {}
+						IIfA:ScanCurrentCharacterAndBank()
+					end,
+				}, -- button end
+
 				{	type 	= "description",
 					title 	= "Ignore or delete characters",
 					text 	= "removes or un-tracks a character. \nWarning: This change will be applied immediately.",