[ create a new paste ] login | about

Link: http://codepad.org/dlhrKHRC    [ raw code | output | fork ]

Lua, pasted on Mar 21:
function displayMessage(msg)
	inInstance, instanceType = IsInInstance()

	local messageType = "PARTY"

	if AnnouncerPARTY==true then
		--
	elseif inInstance == 1 and instanceType ~= "none" then
		messageType = "INSTANCE_CHAT"
	end

	if (AnnouncerRW == true and (UnitIsGroupAssistant("player") or UnitIsGroupLeader("player")) and IsInRaid()) then
		messageType = "RAID_WARNING"
	end
	
	SendChatMessage(msg,messageType)
end

function printMessage(msg)
	print("|cff7f7fff[CA 2] "..msg)
end

function OnEvent(self, event, ...)
	if event == "VARIABLES_LOADED" then
	
		if AnnouncerState==nil then
			AnnouncerState = true
		end

		if AnnouncerPARTY==nil then
			AnnouncerPARTY = true
		end
		if AnnouncerRW==nil then
			AnnouncerRW = false
		end		
		
		if AnnouncerState==true then
			conjuredAnnouncer:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
		else
			conjuredAnnouncer:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
		end
		
		printMessage("Conjured Announcer loaded.")
		printMessage("Type /can or /cann for options. Announcer state is: "..getState(AnnouncerState))
			
		SlashCmdList["FFDCMD"] = SlashCommand;
		SLASH_FFDCMD1 = "/can";
		SLASH_FFDCMD2 = "/cann";
	else
		 local timestamp, type, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellID, spellName = ...
		
		--print (type,spellID,sourceName,destName)
		--printMessage (searchTable)

		if (AnnouncerState == true and (UnitInParty(sourceName) or UnitInRaid(sourceName)) and (type=="SPELL_CREATE" or type=="SPELL_SUMMON" or type=="SPELL_CAST_SUCCESS") and GetNumGroupMembers()>0 and checkTable[spellID]~=nil) then
			--printMessage ("**************")
			--printMessage (type,spellID,sourceName,destName)
			
			-- use this for cauldrons, they show up only for SPELL_CAST_START and have null for destName
			if (destName==nil) then
				destName = spellName
			end

			
			if (destName=="Create Soulwell") then
				return
			end
			
		local _, class = GetPlayerInfoByGUID(sourceGUID)
		local color, message = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
			if color then
				message = ("{rt1}\124c%s%s\124r has created %s{rt1}"):format(color.colorStr, sourceName, GetSpellLink(spellID))
			else
				message = ("{rt1}%s has created %s{rt1}"):format(sourceName, GetSpellLink(spellID))
			end	
			

			
			if (antispamtable[message]==nil) then
				antispamtable[message] = time()
				displayMessage(message)
			else			
				if (time()-antispamtable[message])>10 then
					antispamtable[message] = time()
					displayMessage(message)
				end
			end
		end
	end
end

function helptxt()
	printMessage(" Conjured Announcer 2. Current state: "..getState(AnnouncerState))
	printMessage(" ")	
	printMessage(" Activate : /can on")
	printMessage(" Deactivate: /can off")
	printMessage(" Announce on party: /can party")
	printMessage(" Announce on group chat: /can group")
	printMessage(" Announce on raid warning: /can rw")
end

function SlashCommand(msg)
	local argc, argv = 0, {}
	gsub(msg, "[^%s]+", function (word) argc=argc+1; argv[argc]=word; end);

	if (argc == 1) then
		if (argv[1] == "help") then
			helptxt()
		elseif (argv[1] == "off") then
			printMessage("Announcer state OFF. Type /can on to activate")
			AnnouncerState = false;		
			conjuredAnnouncer:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
		elseif  (argv[1] == "on") then
			printMessage("Announcer state ON. Type /can off to deactivate")
			AnnouncerState = true
			conjuredAnnouncer:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
		elseif  (argv[1] == "party") then
			AnnouncerPARTY = true
			printMessage("Announcer set to PARTY.")
		elseif  (argv[1] == "rw") then
			AnnouncerRW = not AnnouncerRW
			printMessage("Announcer using raidwarning: "..getState(AnnouncerRW))
		elseif  (argv[1] == "group") then
			AnnouncerPARTY = false
			printMessage("Announcer set to GROUP.")			
		end
	else
		helptxt()
	end
end

function getState(cond)
	if cond==true then
		return "ON"	
	else
		return "OFF"
	end
end

	
--67826 Jeeves
--54711 Scrapbot
--44389 Field Repair Bot 110G
--22704 Field Repair Bot 74A
--57426 Fish Feast
--57301 Great Feast
--54710 MOLL-E

--92824 Ritual of Refreshment
--43987 Refreshment Portal
--698   Ritual of Summoning
--29893 Ritual of Souls

--41458 Cauldron of Major Arcane Protection
--41500 Cauldron of Major Fire Protection
--41501 Cauldron of Major Frost Protection
--92649 Cauldron of Battle
--92712 Big Cauldron of Battle
--87915 Goblin Barbecue Feast
--87644 Seafood Magnifique Feast
--87643 Broiled Dragon Feast

--145196 Pandaren Treasure Noodle Cart Kit
--145169 Deluxe Noodle Cart
--145166 Noodle Cart	
--104958 Pandaren Banquet
--126492 Banquet of the Grill
--126494 Great Banquet of the Grill
--126501 Banquet of the Oven
--145061 Deluxe Noodle Cart Kit
--145038 Noodle Cart Kit
--126502 Great Banquet of the Oven
--126504 Great Banquet of the Brew
--126498 Great Banquet of the Pot
--126500 Great Banquet of the Steamer
--126496 Great Banquet of the Wok
--105193 Great Pandaren Banquet
--126503 Banquet of the Brew
--126497 Banquet of the Pot
--126499 Banquet of the Steamer
--126495 Banquet of the Wok

--10059 STORMWIND PORTAL
--11416 IRONFORGE PORTAL
--11417 ORGRIMMAR PORTAL
--11418 UNDERCITY PORTAL
--11419 DARNASSUS PORTAL
--11420 THUNDER BLUFF PORTAL
--32266 EXODAR PORTAL
--32267 SILVERMOON PORTAL
--33691 SHATTRATH PORTAL
--35717 SHATTRATH PORTAL
--49360 THERAMORE PORTAL
--49361 STONARD PORTAL
--53142 DALARAN PORTAL
--88345 TOL BARAD PORTAL
--88346 TOL BARAD PORTAL
--120146 ANCIENT DALARAN PORTAL
--132620 VALE OF ETERNAL BLOSSOMS PORTAL
--132626 VALE OF ETERNAL BLOSSOMS PORTAL

spellIDS   = {67826,54711,44389,22704,57426,57301,54710,92824,43987,698,29893,41458,41500,41501,92649,92712,87915,87644,87643,145196,145169,145166,104958,126492,126494,126501,145061,145038,126502,126504,126498,126500,126496,105193,126503,126497,126499,126495,10059,11416,11417,11418,11419,11420,32266,32267,33691,35717,49360,49361,53142,88345,88346,120146,132620,132626}
checkTable = {}

for i=1,#spellIDS do checkTable[spellIDS[i]]=1 end

msgType = {}
msgType["pvp"]="BATTLEGROUND"
msgType["arena"]="PARTY"
msgType["party"]="PARTY"
msgType["instance"]="INSTANCE"
msgType["raid"]="RAID"

antispamtable = {}



conjuredAnnouncer = CreateFrame("Frame")
conjuredAnnouncer:RegisterEvent("VARIABLES_LOADED")
conjuredAnnouncer:SetScript("OnEvent", OnEvent)


Output:
1
2
3
4
line 218: attempt to call global 'CreateFrame' (a nil value)
stack traceback:
	t.lua:218: in main chunk
	[C]: ?


Create a new paste based on this one


Comments: