How do you access event arguments?

Nov 24, 2009 at 6:20 AM

I just downloaded the Addon Studio today, and am pretty new to addon development.  In experimenting with WoW's API, I started looking at updating a label based on the UNIT_AURA event.  This event returns a UnitID as an argument.  According to this WowWiki article, an event's arguments are stored in the vararg variable (...) and can be accessed within the event handler.  However, with everything I've tried the ... is either nil or throws an error when I try to access it.  So, how do I access the event's arguments within the event handler?

Dec 1, 2009 at 5:20 PM


Below is a sample piece of code I use for handling the Chat_Msg_Loot event. There are two good sites to use for these types of questions. and Hope this helps.

function CHAT_MSG_LOOT(event,msg)
	local player = string.sub(arg1,1, string.find(arg1," ")-1)
	if (player == "You") then  
		player = UnitName("player")         
		--local itemName = string.sub(arg1, string.find(arg1,"%["), string.find(arg1,"%]"))
		local _,_,itemID = strfind(arg1, "(%d+):")
		--check to see if there was more than one looted
		local qstart = string.find(arg1,"%rx") 
		local quantity = 1
		--if more than one was looted then find quantity
	if qstart then
		quantity = string.sub(arg1, qstart + 2, string.find(arg1,"%.") - 1)
	if itemID then
		--set Item Info variables
		local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemID)
		--only count those that are abve the selected Quality Threshhold
		if quality >= self.db.char.personalloot.qualityThreshold then
			--create new item
			local dateReceived = date()
			local totalLooted = 1
			--loop through items to see if it has been looted before
			for idx,value in ipairs(self.db.char.personalloot.items) do
                    --if the item has been looted before then increment total looted by 1
                    if self.db.char.personalloot.items[idx].ItemID == itemID then
                        self.db.char.personalloot.items[idx].TotalLooted = self.db.char.personalloot.items[idx].TotalLooted + quantity
                        totalLooted = self.db.char.personalloot.items[idx].TotalLooted
			--new item table
			local newitem = {Name = name,
                    Link = link,
                    ItemID = itemID,
                    Quality = quality,
                    ItemLevel = iLevel,
                    ReqLevel = reqLevel,
                    Class = class,
                    Subclass = subclass,
                    MaxStack = maxStack,
                    EquipSlot = equipSlot,
                    Texture = texture,
                    VendorPrice = vendorPrice,
                    TotalLooted = quantity,
                    DateReceived = dateReceived,}
			--if this is the first time looting add to table
			if totalLooted <= 1 then