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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 27 ■ API <strong>Reference</strong> 553itemIDThe itemID uniquely identifies an item; usable with APIs such as GetItemInfo().These identifiers match those utilized on database sites such as http://wowhead.com.itemLocationThe itemLocation is a bitfield describing the location <strong>of</strong> an item owned by theplayer. The following example code illustrates masks that can be compared with anitemLocation to determine the exact location described:local ITEM_INVENTORY_PLAYER = 0x00100000local ITEM_INVENTORY_BACKPACK = 0x00200000local ITEM_INVENTORY_BAGS = 0x00400000local ITEM_INVENTORY_BANK = 0x00800000local MASK_BAG = 0xf00local MASK_SLOT = 0x3flocal bagMap = {[0x100] = 1,[0x200] = 2,[0x400] = 3,[0x800] = 4,}local function ItemInBag(itemLocation)if bit.b<strong>and</strong>(itemLocation, ITEM_INVENTORY_BAGS) > 0 thenlocal bag = bagMap[bit.b<strong>and</strong>(itemLocation, MASK_BAG)]local slot = bit.b<strong>and</strong>(itemLocation, MASK_SLOT)return bag, slotelseif bit.b<strong>and</strong>(itemLocation, ITEM_INVENTORY_BACKPACK) > 0 thenlocal slot = bit.b<strong>and</strong>(itemLocation, MASK_SLOT)return 0, slotendendlocal function ItemEquipped(itemLocation)if bit.b<strong>and</strong>(itemLocation, ITEM_INVENTORY_PLAYER) > 0 thenlocal slot = bit.b<strong>and</strong>(itemLocation, MASK_SLOT)return slotendenditemQualityitemQuality, unsurprisingly, indicates the quality (or rarity) <strong>of</strong> an item. Possiblevalues <strong>and</strong> examples:1. Poor (gray): Broken I.W.I.N. Button2. Common (white): Archmage Vargoth’s Staff3. Uncommon (green): X-52 Rocket Helmet4. Rare / Superior (blue): Onyxia Scale Cloak

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

Saved successfully!

Ooh no, something went wrong!