diff ReagentMaker.lua @ 38:aa2f6965c0f6

Add fancy errors/warnings and block recursion when a recipe has many reagents
author contrebasse
date Fri, 29 Apr 2011 23:38:43 +0200
parents 218e1dd1b821
children c6a1f1cf560c
line wrap: on
line diff
--- a/ReagentMaker.lua	Fri Apr 29 22:56:49 2011 +0200
+++ b/ReagentMaker.lua	Fri Apr 29 23:38:43 2011 +0200
@@ -122,7 +122,7 @@
 	if #(A.data[reagentID]) == 1 and not A.data[reagentID].spell then
 		local numMakable, reagentIndex = A.numMakable(reagentID)
 		if not numMakable then
-			print("Sorry, I can't determine the number of makables reagents...")
+			A.Error("The recipe to make the reagent seems to be hidden, it is not makable.")
 			return
 		end
 		if numMakable>0 then
@@ -132,11 +132,12 @@
 
 		-- If we can make the item needed to make the reagent, open a window to make it
 		-- one step recursion, enables to mill to create an ink
-		if A.data[A.data[reagentID][1][1]] then
+		if (not A.data[reagentID].manyReagents) and A.data[A.data[reagentID][1][1]] then
 			A.externalCraftWindow(A.data[reagentID][1][1],reagentID)
 		else
-			print("Sorry, couldn't make reagent...")
+			A.Error("You do not have enough reagents to craft ["..(GetItemInfo(reagentID) or "item #"..reagentID).."]")
 		end
+		return
 	else
 		A.externalCraftWindow(reagentID)
 	end -- if