12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 11 ■ Exploring the <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong> API 197The pipe (|) character is used in <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong> as an escape character,much like Lua itself uses the backslash (\). The hyperlink begins with a |H,followed by the data <strong>for</strong> the hyperlink. In the case <strong>of</strong> item links, this is just theitem string itself. The data ends with |h, followed by the text that is actuallydisplayed in the hyperlink, including the left <strong>and</strong> right brackets. The hyperlinkends with a final |h. To color the link, you can wrap it using color codes.For example, a script that can print a hyperlink <strong>for</strong> your Hearthstone mightlook like this:print(“|cffffffff|Hitem:6948:0:0:0:0:0:0:0:0|h[Hearthstone]|h|r“)The color code <strong>for</strong> white is specified, the hyperlink data is included, <strong>and</strong> thetext <strong>of</strong> the link itself follows. You may encounter different types <strong>of</strong> hyperlinksin your exploration <strong>of</strong> the <strong>WoW</strong> API, but you won’t find yourself creatingthem very <strong>of</strong>ten. More <strong>of</strong>ten than not, when you need a hyperlink you simplyquery the API <strong>and</strong> use whatever is returned.Using the Item APIOnce you have an item identifier, the item API is simple to use. In particularyou are concerned with the GetItemInfo() function, which takes in such anidentifier <strong>and</strong> returns the following:name—The name <strong>of</strong> the item.link—A hyperlink <strong>for</strong> the item.quality—Quality (rarity) level <strong>of</strong> the item.iLevel—Internal level <strong>of</strong> the item.reqLevel—Minimum character level required to use or equip the item.class—Localized name <strong>of</strong> the item’s class/type.subclass—Localized name <strong>of</strong> the item’s subclass/subtype.maxStack—Maximum stack size <strong>for</strong> the item (that is, largest number <strong>of</strong>items that can be held in a single bag slot).equipSlot—Non-localized token identifying the inventory type <strong>of</strong> theitem.texture—Pathtoanicontexture<strong>for</strong>theitem.vendorPrice—Price an NPC vendor will pay to buy the item from theplayer.We are only concerned with the item’s name, which is the first return fromthe function. You will use this to sort the items once you’ve finished scanning.To prevent against item scanning, where someone tries to get in<strong>for</strong>mationabout items that aren’t yet in the game, this function returns only in<strong>for</strong>mationabout those items that the player has seen. In particular, the item must exist inthe player’s local item cache.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!