View Single Post
06-22-09, 04:30 AM   #6
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
That should all work apart from
Code:
me.listOfText = {
    "Ringo says: Uuuuuuggggghhhhh....", --note \" for quotes, since a literal " would close the string
    "Ringo says: I'm not feeling so well...",
    "Ringo says: Maybe... you could carry me?",
    "Ringo says: The heat... I can't take it...",
}
because the first argument from CHAT_MSG_MONSTER_* isn't the formatted string and only has the message, apart from CHAT_MSG_MONSTER_EMOTE, which includes %s where %s is the monster name, i.e. "%s keels over and throws up" (a lovely image I know).

Also "frame" should start with a capital F ("Frame").

Code:
local addon = CreateFrame("Frame", "EscortEventAlert")


local triggers = {
	CHAT_MSG_MONSTER_EMOTE = {
		["<monster emote message>"] = true --remember include %s where the monster name should be
	}
	CHAT_MSG_MONSTER_SAY = {
		["<monster say message>"] = true
	}
	
	CHAT_MSG_MONSTER_WHISPER = {
		["<monster whisper message>"] = true
	}
}

addon:RegisterEvent("CHAT_MSG_MONSTER_EMOTE")
addon:RegisterEvent("CHAT_MSG_MONSTER_SAY")
addon:RegisterEvent("CHAT_MSG_MONSTER_WHISPER")

local function OnEvent(self, event, msg, monster)
	if triggers[event][msg] then
		PlaySound("RaidWarning")
		RaidWarningFrame:AddMessage("Head's Up!  "..monster.." needs help!!!")
	end
end

addon:SetScript("OnEvent", OnEvent)

addon.triggers = triggers
heres something which will only match exact cases so should be marginally more efficient, but requires EXACT matches. Also it might be an idea for later to allow localisation of the message strings.

Hope this helps.
  Reply With Quote