Thread Tools Display Modes
01-08-10, 09:00 AM   #1
Pseudopod
A Deviate Faerie Dragon
Join Date: Apr 2008
Posts: 16
Question Alt-click to buy full stack. ONLY.

I would like to see the most minimal addon that would only enable alt-clicking to buy full stack of anything from a vendor.

I have checked BuyEmAll, GnomishVendorShrinker and AltClickToAddItem. The last one is the closest I guess, but uses libraries.

ACTAI uses Ace2, GVS creates its own frame and BEA is just too complicated to modify for the simplistic version.

So, how to do this without any libraries, creating unwanted frames etc?
  Reply With Quote
01-08-10, 09:55 AM   #2
zero-kill
A Firelord
 
zero-kill's Avatar
Join Date: Aug 2009
Posts: 497
What do you say is a "full stack"? Some items stack at maximum 5 items, others can be 10, etc... an addon with logic for that will probably need a library to know the difference.
  Reply With Quote
01-08-10, 10:13 AM   #3
Pseudopod
A Deviate Faerie Dragon
Join Date: Apr 2008
Posts: 16
Full stack is the maximum number the item stacks in one slot. Well, for instance GnomishVendorShrinker does this too without using libraries, I found this in the lua:

local function BuyItem(self, fullstack)
local id = self:GetID()
local link = GetMerchantItemLink(id)
if not link then return end

local _, _, _, _, _, _, _, stack = GetItemInfo(link)
Purchase(id, fullstack and stack or 1)
end

So there's some sort of fullstack information provided by default?
  Reply With Quote
01-08-10, 10:27 AM   #4
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Will stop if extracost is true/1, if the item costs anything like honor, marks, emblems and whatnot.

Please note that this only hooks the function and does not replace CTRL (Dressingroom) or Shift (Split stack)

Code:
hooksecurefunc("MerchantItemButton_OnModifiedClick", function(self, button)
    if MerchantFrame.selectedTab == 1 then
        if IsAltKeyDown() and button=="RightButton" then
            local id=self:GetID()
            local _, _, _, quantity, available, _, extracost = GetMerchantItemInfo(id)
            if not extracost then
                local stack = select(8, GetItemInfo(GetMerchantItemLink(id)))
                local amount = 1
                if quantity < stack then
                    amount = stack/quantity
                end
                if available ~= -1 and available < amount then
                    amount = available
                end
                BuyMerchantItem(id, amount)
            end
        end
    end
end)
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 01-08-10 at 10:35 AM. Reason: Forgot if MerchantFrame.selectedTab == 1 then
  Reply With Quote
01-08-10, 10:55 AM   #5
Pseudopod
A Deviate Faerie Dragon
Join Date: Apr 2008
Posts: 16
Originally Posted by Yourstruly View Post
Will stop if extracost is true/1, if the item costs anything like honor, marks, emblems and whatnot.
Thank you very much indeed
  Reply With Quote
01-08-10, 12:19 PM   #6
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Do you people mind if I use that code for my addon ncImprovedMerchant?
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
01-08-10, 01:22 PM   #7
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Originally Posted by nightcracker View Post
Do you people mind if I use that code for my addon ncImprovedMerchant?
God no, go ahead. No one owns it.

I rewrote it to check if the player can afford it and use the table values of self instead of doing extra checks. I wonder if someone can shorten it any more and re-use values somewhere.

Code:
hooksecurefunc("MerchantItemButton_OnModifiedClick", function(self, button)
    if MerchantFrame.selectedTab == 1 then
        if IsAltKeyDown() and button=="RightButton" then
            local id=self:GetID()
            local extracost = select(7, GetMerchantItemInfo(id))
            if not extracost then
                local stack = select(8, GetItemInfo(self.link))
                local amount = 1
                if self.count < stack then
                    amount = stack / self.count
                end
                if self.numInStock ~= -1 and self.numInStock < amount then
                    amount = self.numInStock
                end
                local money = GetMoney()
                if (self.price * amount) > money then
                    amount = floor(money / self.price)
                end
                if amount > 0 then
                    BuyMerchantItem(id, amount)
                end
            end
        end
    end
end)
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 01-08-10 at 01:25 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Alt-click to buy full stack. ONLY.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off