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.

254 Part II ■ <strong>Programming</strong> in <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong>toFinally, add an attribute definition between the tag <strong>and</strong> the tag <strong>for</strong> BagBuddyItemTemplate:Now when you open BagBuddy, you should be able to use items (such asfood, potions, b<strong>and</strong>ages, <strong>and</strong> quest items) by right-clicking on them.Finding the Right Event Using /eventtraceOne <strong>of</strong> the most challenging aspects <strong>of</strong> writing an addon <strong>for</strong> <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong>is finding the right events to ensure your addon functions properly. Someapplications are very simple, such as using UNIT_HEALTH to monitor the health<strong>of</strong> an in-game unit. Others, such as those dealing with the player’s containers<strong>and</strong> inventory, can be a bit tricky to deal with at times.The Blizzard_DebugTools addon included with the default user interfaceprovides the slash comm<strong>and</strong> /eventtrace that makes tracking down eventin<strong>for</strong>mation a bit easier. The comm<strong>and</strong> has a few different <strong>for</strong>ms:/eventtrace start—Start capturing events, whether or not the windowis shown./eventtrace stop—Stop capturing events./eventtrace—Show the window if it is currently hidden, <strong>and</strong> startcapturing events if the window hasn’t been shown be<strong>for</strong>e. Otherwise,hide the window./eventtrace —If the addon is not currently capturing events,capture exactly events <strong>and</strong> then stop capturing events.The results are displayed <strong>for</strong> you in an easy-to-navigate window, shown inFigure 13-2.You can scroll through the resulting events to view their arguments <strong>and</strong>the time at which they were called. In addition, the event trace will show youhow much time elapsed between two events (if any) <strong>and</strong> how many times thescreen was updated.When you need to find out what events fires under a certain situation (suchas when you cast a spell on an enemy), you can start an event trace <strong>and</strong>replicate the situation. Then you can stop the event trace <strong>and</strong> explore theevents that fired to get the in<strong>for</strong>mation you need.

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

Saved successfully!

Ooh no, something went wrong!