First attempt at writing a World of Warcraft AddOn

I’ve finally decided to have a crack at writing an AddOn for WoW. Clearly it is going to be rubbish, and therefore neither use nor ornament, I’ve decided to do something utterly pointless, just as a test.

So, how about something that listens for the word “chicken” and performs the chicken dance in response?

First, I’ll need a name for this piece of nonesense, which shouldn’t conflict with any other AddOn. So, WABZNASM it is then!

An AddOn needs at least 2 files, the first of which is the .TOC file which defines what the AddOn is and what other files it needs.

Mine is called Wabznasm.toc, and looks like this:

## Interface: 50300
## Title: Wabznasm
## Notes: Stupid Test AddOn
## Author: Tony Blews
## Version: 1.0
Wabznasm.lua

The lines refer to the current interface version of WoW, the title of the AddOn, some waffle, who is responsible, and what the version is. The last line refers to the .LUA file which will contain the programming bits.

So, to the .LUA file, which is called Wabznasm.lua:

local f=CreateFrame("frame")   
f:RegisterEvent("CHAT_MSG_SAY")  
f:SetScript("OnEvent", function(self,event,message,sender) 
     if message:match("chicken") then   
          print( sender .. " said Chicken!")
          DoEmote("chicken",sender)
     end      
end)

These files should go in the World of WarcraftInterfaceAddOnsWabznasm directory, and all should be well. And indeed, it is.

Leave a Reply