diff ReagentMaker.lua @ 82:cf1da2654dc6 v1.0beta3

Expand headers when needed. Not heavily tested, could fail on a slow computer...
author contrebasse
date Sun, 15 May 2011 09:23:15 +0200
parents 32c398de6812
children 996aaa818d04
line wrap: on
line diff
--- a/ReagentMaker.lua	Sun May 15 01:35:38 2011 +0200
+++ b/ReagentMaker.lua	Sun May 15 09:23:15 2011 +0200
@@ -116,8 +116,6 @@
 	if IsModifierKeyDown() and not IsShiftKeyDown() then return end
 	local chooseNumberToCraft = IsShiftKeyDown()
 
-	--A.SaveActiveFilters()
-
 	-- Index of the reagent in the recipe, taken from the button name
 	local reagentRecipeIndex = A.buttonNumber(btn)
 
@@ -129,9 +127,16 @@
 	if not reagentID or not A.data[reagentID] then return end
 
 	-- If only one recipe is known for the reagent, use it
-	if #(A.data[reagentID]) == 1 and not A.data[reagentID][1].macro then
+	if #(A.data[reagentID]) == 1 and not A.data[reagentID][1].macro then	
 		local numMakable, reagentIndex = A.numMakable(reagentID)
-		if not numMakable then
+
+		-- Try to show the recipe once if it was not found
+		if not reagentIndex then
+			A.SaveActiveFilters(A.data[reagentID][1].header)
+			numMakable, reagentIndex = A.numMakable(reagentID)
+		end
+
+		if not numMakable then		
 			A.Error(A.L["The recipe to make the reagent seems to be hidden, it is not makable. Try to remove the filters on the recipes."])
 			return
 		end