Mercurial > wow > reagentmaker
changeset 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 | ef22738aebfe |
children | 71e8b39f056e |
files | ReagentMaker.lua data.lua utils.lua |
diffstat | 3 files changed, 17 insertions(+), 3 deletions(-) [+] |
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
--- 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
--- 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 "")