Here's some minimal code that may help you get the gist of it. Bear in mind I write my addons without xml files so they're pure lua.
Feel free to download my CatchAndPlay addon which is the smallest one I have that checks the events and outputs the result. You should be able to see what I did with that and thus how you can implement your own addon for this purpose.
Code:
local function MyAddon_ExtractAchievementDetails(self,...)
local firstArgument = select(1,...);
local secondArgument = select(2,...);
or
local firstArgument, secondArgument = select(1,...);
print(firstArgument);
print(secondArgument);
end
-- Load any variables and display welcome message
local function MyAddon_LoadVariables(self)
-- Do Stuff Here to Prepare the Addon
self:UnregisterEvent("VARIABLES_LOADED");
end
-- Track Events as required
local function MyAddon_OnEvent(self,event,...)
if ( event == "VARIABLES_LOADED" ) then
MyAddon_LoadVariables(self);
elseif ( event == "CHAT_MSG_ACHIEVEMENT" ) then
MyAddon_ExtractAchievementDetails(self,...);
end
end
-- Register Events and make EventFrame
frame = CreateFrame("Frame","DescriptiveFrameName",UIParent);
frame:RegisterEvent("VARIABLES_LOADED");
frame:RegisterEvent("CHAT_MSG_ACHIEVEMENT);
frame:SetScript("OnEvent",MyAddon_OnEvent);