View Single Post
02-20-14, 02:30 PM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Edit: I guess I should refresh the page before typing my reply when it's been sitting on the reply page for 2 hours because I got distracted by work, but oh well. Leaving this here anyway.

On its own, "calling GetItemInfo" won't actually do anything:

Code:
/run GetItemInfo(6948)
You need additional code to catch the return values and do something with those. Let's say, for the sake of example, that you want to print those values to the chat frame, in which case something like this would probably work:

Lua Code:
  1. hooksecurefunc("ContainerFrameItemButton_OnModifiedClick", function(self, button)
  2.     if button ~= "MiddleButton" or not IsShiftKeyDown() then
  3.         return
  4.     end
  5.     local name, link, rarity, level, minLevel, type, subType, stackCount, equipLoc, texture, sellPrice = GetItemInfo(GetContainerItemID(self:GetParent():GetId(), self:GetID())
  6.     print(format("|T%s:0|t %s", texture, link))
  7.     print("   Quality:", _G["ITEM_QUALITY"..rarity.."_DESC"])
  8.     print("   Item Type:", type)
  9.     print("   Item Subtype:", subType)
  10.     if strlen(equipLoc) > 0 then
  11.         print("   Equip Location:",  equipLoc)
  12.     end
  13.     if level > 1 then
  14.         print("   Item Level:", level)
  15.     end
  16.     if minLevel > 0 then
  17.         print("   Requires Level:", minLevel)
  18.     end
  19.     if sellPrice >= 10000 then
  20.         return format("|cffffd700%d|r%s |cffc7c7cf%d|r%s %d%s", abs(sellPrice / 10000), GOLD_AMOUNT_SYMBOL, abs(mod(sellPrice / 100, 100)), SILVER_AMOUNT_SYMBOL, abs(mod(sellPrice, 100)), COPPER_AMOUNT_SYMBOL)
  21.     elseif sellPrice >= 100 then
  22.         return format("|cffc7c7cf%d|r%s %d%s", abs(mod(sellPrice / 100, 100)), SILVER_AMOUNT_SYMBOL, abs(mod(sellPrice, 100)), COPPER_AMOUNT_SYMBOL)
  23.     else
  24.         return format("%d%s", abs(mod(sellPrice, 100)), COPPER_AMOUNT_SYMBOL)
  25.     end
  26. end)

You probably also need to tell the buttons to respond to middle-clicks, instead of just left- and right-clicks:

Lua Code:
  1. for i = 1, 13 do
  2.     for j = 1, 36 do
  3.         _G["ContainerFrame"..i.."Item"..j]::RegisterForClicks("AnyUp")
  4.     end
  5. end

If you're using a third-party bag addon that doesn't reuse the Blizzard item buttons, you'll need to modify its buttons and hook its click-handling function instead.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote