Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
(Typo fixing, typos fixed: consistant → consistent using AWB)
 
(Created page with "{{Patchbox | Patchname = | Image = | Caption = | Release = 2011-02-08 | Version = 13596 | toc = 40000 | Highlights = | Related = | Pr...")
 
Line 1: Line 1:
  +
{{Patchbox
{{userapi}}
 
  +
| Patchname =
  +
| Image =
  +
| Caption =
  +
| Release = 2011-02-08
  +
| Version = 13596
  +
| toc = 40000
  +
| Highlights =
  +
| Related =
  +
| Prev = 4.0.6
  +
| Current = 4.0.6a
  +
| Next = 4.1.0
  +
}}
   
  +
==User interface==
The intent of this page is to provide a simple, consistent API for addons to query the vendor sell value of an item without the need to individually support every sell value addon in existence. All sell value addons are asked to provide the following global function:
 
  +
* The [[Gear Manager]] makes a sound if you switch gear.
  +
==References==
  +
<references />
   
  +
{{patches}}
sellToVendorPrice = GetSellValue(item);
 
  +
[[Category:World of Warcraft patches|4.0.6 (undocumented changes)]]
 
== Requirements ==
 
* 'item' must take the same values [[API GetItemInfo|GetItemInfo]] does
 
* Must return an int, or nil if unknown price. Only return 0 if you know the item cannot be sold to vendor.
 
 
== Recommended ==
 
Check for existence of the global before you define it and hook it if present. This allows for other sell value addons to provide prices that are not known by your addon.
 
 
== Example Code ==
 
The following code snippets illustrate how to create a hook capable of accepting the same input values as GetItemInfo.
 
 
=== Tekkub's version ===
 
This code will ensure that YourItemPriceFunc is passed an integer itemid, or the hooked function is called if present and your function does not return a value. It is optimized to take advantage of tail calls and avoid useless hook calls.
 
local origGetSellValue = GetSellValue
 
function GetSellValue(item)
 
local id = type(item) == "number" and item or type(item) == "string" and tonumber(item:match("item:(%d+)"))
 
 
if not id and type(item) == "string" then -- Convert item name to itemid, only works if the player has the item in his bags
 
local _, link = GetItemInfo(item)
 
id = link and tonumber(link:match("item:(%d+)"))
 
end
 
 
return id and (YourItemPriceFunc(id) or origGetSellValue and origGetSellValue(id))
 
end
 
 
=== Polarina's version ===
 
Functionally this is the same as Tekkub's version. Just slightly slower due to the extra select() call.
 
'''local''' origGetSellValue = GetSellValue
 
'''function''' GetSellValue(item)
 
'''local''' id, sellval
 
 
'''if''' type(item) == "number" '''then'''
 
id = item
 
<b>else
 
</b><font color="lightblue">-- Acquire the second argument from GetItemInfo.</font><b>
 
local</b> link = select(2, GetItemInfo(item))
 
 
<font color="lightblue">-- Check if 'link' is set before using it.</font>
 
id = link '''and''' tonumber(link:match("item:(%d+)"))
 
<b>end
 
 
if</b> id '''then'''
 
sellval = <font color="lightblue">-- Retrieve the price here...</font><b>
 
end
 
 
</b><font color="lightblue">-- If 'sellval' is not set, fall back to origGetSellValue.</font><b>
 
return</b> sellval '''or''' (id '''and''' origGetSellValue '''and''' origGetSellValue(id))
 
'''end'''
 
 
== Addons ==
 
This function is implemented by the following addons:
 
* [[Informant]] of the [[Auctioneer (AddOn)|Auctioneer]] [[AddOns]] Package by [http://auctioneeraddon.com/ The Auctioneer AddOns Team].
 
* [[User:Rowaasr13#My_addons|ItemDataCache]] (v1.11 and higher).
 
* [http://www.wowace.com/wiki/ItemPriceTooltip ItemPriceTooltip] by [[User:Bam|Bam]].
 
* [http://www.wowinterface.com/downloads/info7035-SellFish.html SellFish] by [[User:Tuller|Tuller]].
 
* [http://www.wowinterface.com/downloads/info7493-Valuation.html Valuation] by [[User:Polarina|Polarina]].
 
* [http://auctionator-addon.com Auctionator] by [[User:Zirco|Zirco]].
 
* [http://wow.curse.com/downloads/wow-addons/details/auctionlite.aspx AuctionLite] by Merial.
 
 
Addons using this function:
 
* [[VendorBait]] by [[User:Tekkub|Tekkub]]
 
* FuBar_GarbageFu
 
 
See also:
 
* [[GetAuctionBuyout]]
 

Revision as of 11:01, 26 February 2011

Icon-patch-22x22 Patch 4.0.6a (undocumented changes)
Release date 2011-02-08
Initial version 13596
Interface .toc 40000

Patch chronology
Useful links
PatchesPatches category

User interface

References