TekNoLogic / StealYourCarbon

WoW Addon - Automatically restock items from vendors and your bank
http://www.tekkub.net
12 stars 9 forks source link

buying forced-stack items #13

Open oscarucb opened 10 years ago

oscarucb commented 10 years ago

Hi - Been using SYC for a long time, one small issue. Some stackable items are only sold by the merchant in fixed stacks (usually a stack of 5), and SYC does not handle this correctly.

One good example that I care about is Golden Glider http://www.wowhead.com/item=104346 which is Unique(20) and only buyable in stacks of 5. If you have 1 in your bags and configured for a full 20 stack, SYC will try to purchase 19 and fail to purchase any ("Error: You can't buy the specified quantity of that item"). In this case it's not possible to buy 19 (without first deleting some in the bags) but it could at least purchase 15.

Here is the simple fix to do that (rather than failing with an error and doing nothing):

169                                 while tobuy > 0 do
170                                         local thisbuy = min(tobuy, stacks[itemID])
+  171                                       if qty and qty > 1 then thisbuy = min(thisbuy, qty) end -- oscarucb : stack-at-a-time purchase
172                                         BuyMerchantItem(i, thisbuy)
173                                         spent = spent + (price/qty)*thisbuy
174                                         tobuy = tobuy - thisbuy
175                                 end

It might also be nice to have an optional feature to "force fill the stack" (by deleting some in the bags first), but I can live without that.