Fix bug in previous update; add "Use current character, whoever that is" to main character dropdown

katkat42 [12-14-14 - 23:56]
Fix bug in previous update; add "Use current character, whoever that is" to main character dropdown
Filename
Common.lua
Provisioning.lua
SousChef.lua
diff --git a/Common.lua b/Common.lua
index d44d8d0..01f28c5 100644
--- a/Common.lua
+++ b/Common.lua
@@ -7,22 +7,22 @@ local BACKPACK = ZO_PlayerInventoryBackpack
 local BANK = ZO_PlayerBankBackpack
 local GUILD_BANK = ZO_GuildBankBackpack

-local COOKING_RANK_2 = [[SousChef\media\Two.dds]]
-local COOKING_RANK_3 = [[SousChef\media\Three.dds]]
-local COOKING_RANK_4 = [[SousChef\media\Four.dds]]
-local COOKING_RANK_5 = [[SousChef\media\Five.dds]]
-local COOKING_RANK_6 = [[SousChef\media\Six.dds]]
-local COOKING_FLAVOUR = [[SousChef\media\Flavour.dds]]
-local COOKING_SPICE =   [[SousChef\media\Spice.dds]]
-local COOKING_SPICEB =   [[SousChef\media\Spice_Flat.dds]]
-local COOKING_RANK_1B = [[SousChef\media\One_flat.dds]]
-local COOKING_RANK_2B = [[SousChef\media\Two_flat.dds]]
-local COOKING_RANK_3B = [[SousChef\media\Three_flat.dds]]
-local COOKING_RANK_4B = [[SousChef\media\Four_flat.dds]]
-local COOKING_RANK_5B = [[SousChef\media\Five_flat.dds]]
-local COOKING_RANK_6B = [[SousChef\media\Six_flat.dds]]
-local COOKING_FLAVOURB = [[SousChef\media\flavour_flat.dds]]
-local COOKING_RANK_1 = [[SousChef\media\One.dds]]
+local COOKING_RANK_1 = [[SousChef/media/One.dds]]
+local COOKING_RANK_2 = [[SousChef/media/Two.dds]]
+local COOKING_RANK_3 = [[SousChef/media/Three.dds]]
+local COOKING_RANK_4 = [[SousChef/media/Four.dds]]
+local COOKING_RANK_5 = [[SousChef/media/Five.dds]]
+local COOKING_RANK_6 = [[SousChef/media/Six.dds]]
+local COOKING_FLAVOUR = [[SousChef/media/Flavour.dds]]
+local COOKING_SPICE =   [[SousChef/media/Spice.dds]]
+local COOKING_RANK_1B = [[SousChef/media/One_flat.dds]]
+local COOKING_RANK_2B = [[SousChef/media/Two_flat.dds]]
+local COOKING_RANK_3B = [[SousChef/media/Three_flat.dds]]
+local COOKING_RANK_4B = [[SousChef/media/Four_flat.dds]]
+local COOKING_RANK_5B = [[SousChef/media/Five_flat.dds]]
+local COOKING_RANK_6B = [[SousChef/media/Six_flat.dds]]
+local COOKING_FLAVOURB = [[SousChef/media/flavour_flat.dds]]
+local COOKING_SPICEB =   [[SousChef/media/Spice_Flat.dds]]

 local GRILLED  = [[/esoui/art/treeicons/provisioner_indexicon_meat_down.dds]]
 local BREADPIE  = [[/esoui/art/treeicons/provisioner_indexicon_baked_down.dds]]
diff --git a/Provisioning.lua b/Provisioning.lua
index f6000a2..89efbb3 100644
--- a/Provisioning.lua
+++ b/Provisioning.lua
@@ -123,8 +123,14 @@ function SousChef:IsOnShoppingList(id)
 			if SousChef.settings.showAltShopping then
 				return true
 			else
-				if SousChef.settings.shoppingList[v][SousChef.settings.mainChar] then
-					return true
+				if SousChef.settings.mainChar == "(current)" then
+					if SousChef.settings.shoppingList[v][GetUnitName("player")] then
+						return true
+					end
+				else
+					if SousChef.settings.shoppingList[v][SousChef.settings.mainChar] then
+						return true
+					end
 				end
 			end
 		end
diff --git a/SousChef.lua b/SousChef.lua
index 88582b5..aef7a70 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -10,7 +10,7 @@ Thanks to Ayantir for the French translations, and sirinsidiator for the German
 SousChef = {}
 SousChef.Utility = {}
 SousChef.Media = {}
-SousChef.version = "2.17"
+SousChef.version = "2.18"

 local SousChef = SousChef
 local u = SousChef.Utility
@@ -76,14 +76,19 @@ end

 -- every time you change the main character in the settings menu, you need to update the "player" cookbook, cookbook index, pantry, and reverse cookbook with the new character's data
 local function ChangeMainChar()
-	SousChef.CookbookIndex = SousChef.settings.CookbookIndex[SousChef.settings.mainChar]
+	if SousChef.settings.mainChar == "(current)" then
+		SousChef.CookbookIndex = SousChef.settings.CookbookIndex[GetUnitName("player")]
+	else
+		SousChef.CookbookIndex = SousChef.settings.CookbookIndex[SousChef.settings.mainChar]
+	end

 	SousChef.Cookbook = {}
 	SousChef.Pantry = {}
 	SousChef.ReverseCookbook = {}
+	if SousChef.CookbookIndex == nil then SousChef.CookbookIndex = {} end
 	for name, data in pairs(SousChef.CookbookIndex) do
 		SousChef.Cookbook[u.CleanString((GetRecipeResultItemInfo(data.listIndex, data.recipeIndex)))] = true
-		local _, _, _, level, _, specialType = GetRecipeInfo(listIndex, recipeIndex)
+		local _, _, _, level, _, specialType = GetRecipeInfo(data.listIndex, data.recipeIndex)
 		for ingredient = 1, data.numIngredients do
 			local ingredientID = u.GetItemID(GetRecipeIngredientItemLink(data.listIndex, data.recipeIndex, ingredient))
 			if ingredient < 3 or not SousChef.settings.showSpecialIngredients then
@@ -437,7 +442,7 @@ local function SousChef_Loaded(eventCode, addOnName)
         sortProvisioningTable = true,
         sortKnownIngredients = false,
 		mainChar = GetUnitName("player"),
-		knownChars = {},
+		knownChars = { "(current)" },
 		autoJunk = false,
 		showAltShopping = true,
 	}
@@ -448,13 +453,18 @@ local function SousChef_Loaded(eventCode, addOnName)
     SousChef.settings = ZO_SavedVars:NewAccountWide("SousChef_Settings", 10, SousChef.lang, defaults)
 	-- if this character isn't in the list of known chars, add it
 	local addMe = true
+	local addCurrent = true
 	for _, v in pairs(SousChef.settings.knownChars) do
-		if GetUnitName("player") == v then addMe = false break end
+		if GetUnitName("player") == v then addMe = false end
+		if v == "(current)" then addCurrent = false end
 	end
 	if addMe then
 		local myName = GetUnitName("player")
 		table.insert(SousChef.settings.knownChars, GetUnitName("player"))
 	end
+	if addCurrent then
+		table.insert(SousChef.settings.knownChars, "(current)")
+	end

 	-- define some slash commands
 	SLASH_COMMANDS['/scstats'] = function()
@@ -469,7 +479,7 @@ local function SousChef_Loaded(eventCode, addOnName)
 	SousChefCreateSettings()

 	-- parse the recipes this character knows, in a second
-	zo_callLater(SousChef.ParseRecipes, 1000)
+	zo_callLater(SousChef.ParseRecipes, 500)

 	SousChef:UpdateProvisioningTable()
 	SousChef:HookGetRecipeInfo()
@@ -479,7 +489,7 @@ local function SousChef_Loaded(eventCode, addOnName)
 	ZO_CreateStringId("SI_BINDING_NAME_SC_MARK_RECIPE", localized.KEY_MARK)

 	-- Now we register for some events, and hook into the function that sets the details on the inventory slot
-	zo_callLater(SousChef.HookEvents, 3000)
+	zo_callLater(SousChef.HookEvents, 2000)
 end

 -- HookEvents() registers the add-on for some events