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.

144 Part II ■ <strong>Programming</strong> in <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong><strong>Creating</strong> an Addon SkeletonBagBuddy consists <strong>of</strong> an XML definition <strong>of</strong> the frames, <strong>and</strong> a Lua scriptthat defines the behavior <strong>and</strong> logic <strong>of</strong> the addon. Start by creating a newdirectory within your Interface\AddOns folder called BagBuddy. Inside thisnew directory create a file called BagBuddy.toc <strong>and</strong> add the following content:## Interface: 30200## Title: BagBuddy## Notes: A h<strong>and</strong>y helper that allows you to filter your inventoryBagBuddy.luaBagBuddy.xmlNow create BagBuddy.xml, adding just the basic definition <strong>of</strong> the element that you have seen be<strong>for</strong>e:Finally, create an empty file called BagBuddy.lua. You won’t be adding anycode to it <strong>for</strong> the next few chapters, but creating it now ensures that the <strong>WoW</strong>client will recognize the file without needing to be restarted.<strong>Creating</strong> a FrameThe <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong> user interface is based around the central concept <strong>of</strong>frames. All textures <strong>and</strong> font strings must belong to a parent frame. Framescan register <strong>for</strong> events <strong>and</strong> receive notification <strong>of</strong> game events. In addition, theuser can interact with frames, <strong>for</strong> example by clicking them. As a result, mostaddons begin with a definition <strong>of</strong> a frame. BagBuddy is no different.In BagBuddy.xml, add the following code inside the element:This code creates a new frame called BagBuddy that is a child <strong>of</strong> UIParent.The frame is given a width <strong>of</strong> 384 <strong>and</strong> a height <strong>of</strong> 512, <strong>and</strong> is anchored to thecenter <strong>of</strong> UIParent, making it appear in the middle <strong>of</strong> the player’s screen.

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

Saved successfully!

Ooh no, something went wrong!