# HG changeset patch # User contrebasse # Date 1304113123 -7200 # Node ID aa2f6965c0f646d8b2938f4df499acd2dd5b2b48 # Parent ef22738aebfeb8d836d42fd5ee899cf8897660a5 Add fancy errors/warnings and block recursion when a recipe has many reagents diff -r ef22738aebfe -r aa2f6965c0f6 ReagentMaker.lua --- 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 diff -r ef22738aebfe -r aa2f6965c0f6 data.lua --- a/data.lua Fri Apr 29 22:56:49 2011 +0200 +++ b/data.lua Fri Apr 29 23:38:43 2011 +0200 @@ -314,6 +314,7 @@ end -- for if newSpell then A.data[itemID].spellLink = recipeLink + A.data[itemID].manyReagents = A.data[itemID].manyReagents or GetTradeSkillNumReagents(i)>1 tinsert(A.data[itemID],{reagentID,reagentCount,minMade,maxMade,spellName=skillName}) end -- if end -- if diff -r ef22738aebfe -r aa2f6965c0f6 utils.lua --- a/utils.lua Fri Apr 29 22:56:49 2011 +0200 +++ b/utils.lua Fri Apr 29 23:38:43 2011 +0200 @@ -13,6 +13,18 @@ DEFAULT_CHAT_FRAME:AddMessage(msg or "nil",1,0,0) end -- function +-- Messages to the user +function A.Warn(msg) + if not msg then return end + local event = "UI_INFO_MESSAGE" + UIErrorsFrame_OnEvent(UIErrorsFrame, event, msg) +end -- function +function A.Error(msg) + if not msg then return end + local event = "UI_ERROR_MESSAGE" + UIErrorsFrame_OnEvent(UIErrorsFrame, event, msg) +end -- function + -- Returns the item ID from its link function A.link2ID(link) return tonumber(select(3,sfind(link or "", "-*:(%d+)[:|].*")) or "")