Mercurial > wow > reagentmaker
comparison 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 |
comparison
equal
deleted
inserted
replaced
37:ef22738aebfe | 38:aa2f6965c0f6 |
---|---|
120 | 120 |
121 -- If only one recipe is known for the reagent, use it | 121 -- If only one recipe is known for the reagent, use it |
122 if #(A.data[reagentID]) == 1 and not A.data[reagentID].spell then | 122 if #(A.data[reagentID]) == 1 and not A.data[reagentID].spell then |
123 local numMakable, reagentIndex = A.numMakable(reagentID) | 123 local numMakable, reagentIndex = A.numMakable(reagentID) |
124 if not numMakable then | 124 if not numMakable then |
125 print("Sorry, I can't determine the number of makables reagents...") | 125 A.Error("The recipe to make the reagent seems to be hidden, it is not makable.") |
126 return | 126 return |
127 end | 127 end |
128 if numMakable>0 then | 128 if numMakable>0 then |
129 A.craft(reagentID,reagentRecipeIndex,reagentIndex,numMakable,chooseNumberToCraft) | 129 A.craft(reagentID,reagentRecipeIndex,reagentIndex,numMakable,chooseNumberToCraft) |
130 return | 130 return |
131 end | 131 end |
132 | 132 |
133 -- If we can make the item needed to make the reagent, open a window to make it | 133 -- If we can make the item needed to make the reagent, open a window to make it |
134 -- one step recursion, enables to mill to create an ink | 134 -- one step recursion, enables to mill to create an ink |
135 if A.data[A.data[reagentID][1][1]] then | 135 if (not A.data[reagentID].manyReagents) and A.data[A.data[reagentID][1][1]] then |
136 A.externalCraftWindow(A.data[reagentID][1][1],reagentID) | 136 A.externalCraftWindow(A.data[reagentID][1][1],reagentID) |
137 else | 137 else |
138 print("Sorry, couldn't make reagent...") | 138 A.Error("You do not have enough reagents to craft ["..(GetItemInfo(reagentID) or "item #"..reagentID).."]") |
139 end | 139 end |
140 return | |
140 else | 141 else |
141 A.externalCraftWindow(reagentID) | 142 A.externalCraftWindow(reagentID) |
142 end -- if | 143 end -- if |
143 --A.RestoreActiveFilters() | 144 --A.RestoreActiveFilters() |
144 end -- function | 145 end -- function |