Mercurial > wow > itemauditor
comparison Modules/Crafting.lua @ 156:d108b0112be3
I removed all of the vellums that were removed from the game. This also allowed me to make the one remaining vellum count toward the materials required to craft a scroll.
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Fri, 10 Dec 2010 00:48:20 -0800 |
| parents | 613fd4bc6999 |
| children | fbfd9dfa6d2b |
comparison
equal
deleted
inserted
replaced
| 155:802abe9b0b4c | 156:d108b0112be3 |
|---|---|
| 9 local validateMoney = ItemAuditor.validateMoney | 9 local validateMoney = ItemAuditor.validateMoney |
| 10 local parseMoney = ItemAuditor.parseMoney | 10 local parseMoney = ItemAuditor.parseMoney |
| 11 | 11 |
| 12 local realData = {} | 12 local realData = {} |
| 13 local nameMap = nil | 13 local nameMap = nil |
| 14 | |
| 15 local vellumLevelMap = { | |
| 16 [38682] = 37602, -- Armor Vellum => Armor Vellum II | |
| 17 [37602] = 43145, -- Armor Vellum II => Armor Vellum III | |
| 18 [39349] = 39350, -- Weapon Vellum => Weapon Vellum II | |
| 19 [39350] = 43146, -- Weapon Vellum II => Weapon Vellum III | |
| 20 } | |
| 21 | 14 |
| 22 function Crafting:OnInitialize() | 15 function Crafting:OnInitialize() |
| 23 self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") | 16 self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") |
| 24 end | 17 end |
| 25 | 18 |
| 285 | 278 |
| 286 --[[ | 279 --[[ |
| 287 When enchanting UseContainerItem seems to be protected, so the enchants | 280 When enchanting UseContainerItem seems to be protected, so the enchants |
| 288 have to be done one at a time. | 281 have to be done one at a time. |
| 289 ]] | 282 ]] |
| 290 local function useVellum(vellumID, idealVellum) | 283 local function useVellum(vellumID) |
| 291 for bagID = 0, NUM_BAG_SLOTS do | 284 for bagID = 0, NUM_BAG_SLOTS do |
| 292 for slotID = 0, GetContainerNumSlots(bagID) do | 285 for slotID = 0, GetContainerNumSlots(bagID) do |
| 293 local link = GetContainerItemLink(bagID, slotID) | 286 local link = GetContainerItemLink(bagID, slotID) |
| 294 local id = Utils.GetItemID(link); | 287 local id = Utils.GetItemID(link); |
| 295 if id == vellumID then | 288 if id == vellumID then |
| 296 if idealVellum then | |
| 297 ItemAuditor:Print("Using %s instead of %s.", | |
| 298 select(2, GetItemInfo(vellumID)), | |
| 299 select(2, GetItemInfo(idealVellum)) | |
| 300 ) | |
| 301 end | |
| 302 UseContainerItem(bagID, slotID) | 289 UseContainerItem(bagID, slotID) |
| 303 return | 290 return |
| 304 end | 291 end |
| 305 end | 292 end |
| 306 end | |
| 307 if vellumLevelMap[vellumID] then | |
| 308 return useVellum(vellumLevelMap[vellumID], idealVellum or vellumID) | |
| 309 end | 293 end |
| 310 end | 294 end |
| 311 | 295 |
| 312 btnProcess:SetScript("OnClick", function (self, button, down) | 296 btnProcess:SetScript("OnClick", function (self, button, down) |
| 313 local data = ItemAuditor:GetCraftingRow(1) | 297 local data = ItemAuditor:GetCraftingRow(1) |
| 318 CastSpellByName(data.tradeskillName) | 302 CastSpellByName(data.tradeskillName) |
| 319 end | 303 end |
| 320 | 304 |
| 321 local queue = data.queue | 305 local queue = data.queue |
| 322 local vellumID = nil | 306 local vellumID = nil |
| 323 _, _, _, _, altVerb = GetTradeSkillInfo(data.tradeSkillIndex) | 307 local altVerb = select(5, GetTradeSkillInfo(data.tradeSkillIndex)) |
| 324 if altVerb == 'Enchant' and LSW.scrollData[data.recipeID] ~= nil then | 308 if altVerb == 'Enchant' then |
| 325 vellumID = LSW.scrollData[data.recipeID]["vellumID"] | 309 vellumID = 38682 |
| 326 queue = 1 | 310 queue = 1 |
| 327 end | 311 end |
| 328 ItemAuditor:Print('Crafting %sx%s', data.link, queue) | 312 ItemAuditor:Print('Crafting %sx%s', data.link, queue) |
| 329 DoTradeSkill(data.tradeSkillIndex, queue) | 313 DoTradeSkill(data.tradeSkillIndex, queue) |
| 330 if vellumID then | 314 if vellumID then |
| 462 | 446 |
| 463 | 447 |
| 464 | 448 |
| 465 local tableData = {} | 449 local tableData = {} |
| 466 function ItemAuditor:UpdateCraftingTable() | 450 function ItemAuditor:UpdateCraftingTable() |
| 467 if LSW == nil then | |
| 468 self:Print("This feature requires LilSparky's Workshop.") | |
| 469 return | |
| 470 end | |
| 471 if GetAuctionBuyout ~= nil then | 451 if GetAuctionBuyout ~= nil then |
| 472 elseif AucAdvanced and AucAdvanced.Version then | 452 elseif AucAdvanced and AucAdvanced.Version then |
| 473 else | 453 else |
| 474 self:Print("This feature requires Auctionator, Auctioneer, AuctionLite, or AuctionMaster.") | 454 self:Print("This feature requires Auctionator, Auctioneer, AuctionLite, or AuctionMaster.") |
| 475 return | 455 return |
| 493 local itemLink = GetTradeSkillItemLink(i) | 473 local itemLink = GetTradeSkillItemLink(i) |
| 494 local itemId = Utils.GetItemID(itemLink) | 474 local itemId = Utils.GetItemID(itemLink) |
| 495 local vellumID = nil | 475 local vellumID = nil |
| 496 | 476 |
| 497 --Figure out if its an enchant or not | 477 --Figure out if its an enchant or not |
| 498 _, _, _, _, altVerb = GetTradeSkillInfo(i) | 478 local altVerb = select(5, GetTradeSkillInfo(i)) |
| 499 if LSW.scrollData[itemId] ~= nil and altVerb == 'Enchant' then | 479 if LSW and LSW.scrollData[itemId] ~= nil and altVerb == 'Enchant' then |
| 500 -- Ask LSW for the correct scroll | 480 -- Ask LSW for the correct scroll |
| 501 local sd = LSW.scrollData[itemId] | 481 itemId = LSW.scrollData[itemId] |
| 502 itemId = sd.scrollID | 482 vellumID = 38682 |
| 503 vellumID = sd.vellumID | |
| 504 end | 483 end |
| 505 | 484 |
| 506 local recipeLink = GetTradeSkillRecipeLink(i) | 485 local recipeLink = GetTradeSkillRecipeLink(i) |
| 507 local stackSize = 1 | 486 local stackSize = 1 |
| 508 if recipeLink ~= nil and itemId ~= nil then | 487 if recipeLink ~= nil and itemId ~= nil then |
| 598 numOwned[reagent.link] = ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(reagent.link)) | 577 numOwned[reagent.link] = ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(reagent.link)) |
| 599 end | 578 end |
| 600 data.haveMaterials = min(data.haveMaterials, floor(numOwned[reagent.link] / needEach)) | 579 data.haveMaterials = min(data.haveMaterials, floor(numOwned[reagent.link] / needEach)) |
| 601 numOwned[reagent.link] = numOwned[reagent.link] - reagent.count | 580 numOwned[reagent.link] = numOwned[reagent.link] - reagent.count |
| 602 | 581 |
| 603 -- Vellums count in cost, but not against whether or not you have the mats. | 582 if numOwned[reagent.link] < 0 then |
| 604 -- I chose to do it this way because you can use a higher level of vellum | |
| 605 -- and I'm not sure the best way to determine cost and materials in that situation. | |
| 606 if numOwned[reagent.link] < 0 and not vellumLevelMap[reagent.itemID] then | |
| 607 reagent.need = min(reagent.count, abs(numOwned[reagent.link])) | 583 reagent.need = min(reagent.count, abs(numOwned[reagent.link])) |
| 608 end | 584 end |
| 609 end | 585 end |
| 610 data.haveMaterials = max(0, data.haveMaterials) | 586 data.haveMaterials = max(0, data.haveMaterials) |
| 611 end | 587 end |
