1. #1

    Post Lua addon question

    So i've been trying to revive a dead addon i found on curse for use in my guild's raids. (I can't link it but it was called Herald) I'm pretty new to lua and I thought the addon was working great. It triggers properly when one of the listed spell IDs is cast, however it then will repeat whatever that message was on any of my consecutive spell casts.

    For example:

    If i cast a MOLL-E it will say correctly: "> Joe has created a [MOLL-E] <"
    However it will then repeat that message on any successful spell cast. I can cast a blood boil and it will repeat that same MOLL-E message. If i drop another item it will display the correct message, but then will again loop on successful cast.

    The formatting got distorted a bit but here is the code i have:
    Code:
    -- Author: Land
    local AnnouncerSpeaks = ""
    
    local frame = CreateFrame("Frame")
    
    local msgType = {
    ["pvp"] = "BATTLEGROUND",
    ["arena"] = "PARTY",
    ["party"] = "PARTY",
    ["raid"] = "RAID",
    }
    
    local antispam = {}
    
    function AnnouncerChatter()
    	local inGroup = IsInGroup()
      local IsRaid = IsInRaid()
    	local inInstance, instanceType = IsInInstance()
    	local AnnouncerType = ""
    
    	if AnnouncerSay==true then
    		AnnouncerType = "SAY"
    	elseif IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
    		AnnouncerType = "INSTANCE_CHAT"
      elseif IsInRaid() then
        AnnouncerType = "RAID"
    	elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
    		AnnouncerType = msgType[instanceType]
    	end
    
    	if (AnnouncerRW == true and (UnitIsGroupAssistant("player") or UnitIsGroupLeader("player")) and AnnouncerType=="RAID") then
    		AnnouncerType = "RAID_WARNING"
    	end
    	SendChatMessage(AnnouncerSpeaks, AnnouncerType)
    end
    
    local function handler (msg)
    	if msg == '' then
    		AnnouncerHelp()
    	elseif msg == 'on' then
    		Announcer = true
    		frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    		print("Announcer is currently: "..getStatus(Announcer))
    	elseif msg == 'off' then
    		Announcer = false
    		frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    		print("Announcer is currently: "..getStatus(Announcer))
    	elseif msg == 'say' then
    		AnnouncerSay = true
    		print("Announcer is announcing on "..CheckStatus().." .")
    	elseif msg == 'rw' then
        AnnouncerRW = not AnnouncerRW
    		print("Announcer is announcing on raid warning when it can.")
    	elseif msg == 'group' then
    		AnnouncerSay = false
    		print("Announcer is announcing on "..CheckStatus().." .")
    	elseif msg == 'status' then
    		print("Announcer is currently: "..getStatus(Announcer))
    		print("Announcer is announcing to: "..CheckStatus())
    	end
    end
    
    SlashCmdList["Announcer"] = handler;
    SLASH_Announcer1 = "/Announcer"
    
    function AnnouncerHelp()
    	print("Announcer is currently: "..getStatus(Announcer))
    	print("To check the status of Announcer: /Announcer status")
    	print("To turn on Announcer: /Announcer on")
    	print("To turn off Announcer: /Announcer off")
    	print("To announce in /say: /Announcer say")
    	print("To announce in /party: /Announcer group")
    	print("To announce in /raidwarning: /Announcer rw")
    end
    
    function getStatus(cond)
    	if cond==true then
    		return "|cffff0000Speaking|r"	
    	else
    		return "|cffff0000Silent|r"
    	end
    end
    
    function CheckStatus()
    	if AnnouncerRW == true then
    		return "|cffff0000Raid Warnings if Lead/Assist|r"
    	elseif AnnouncerSay == false then
    		return "|cffff0000Group|r"
    	end
    	return "|cffff0000Says|r"
    end
    
    local AnnouncerPortals = {
    	[11419] = true, -- Portal: Darnassus
      [32266] = true, -- Portal: Exodar
      [11416] = true, -- Portal: Ironforge
      [11417] = true, -- Portal: Orgrimmar
      [32267] = true, -- Portal: Silvermoon
      [10059] = true, -- Portal: Stormwind 
      [49360] = true, -- Portal: Theramore
      [11420] = true, -- Portal: Thunder Bluff
      [11418] = true, -- Portal: Undercity
      [49361] = true, -- Portal: Stonard
      [120146] = true, -- Ancient Portal: Dalaran
      [53142] = true, -- Portal: Dalaran - Northrend
      [224871] = true, -- Portal: Dalaran - Broken Isles
      [88345] = true, -- Portal: Tol Barad
      [88346] = true, -- Portal: Tol Barad
      [132620] = true, -- Portal: Vale of Eternal Blossoms
      [132626] = true, -- Portal: Vale of Eternal Blossoms
      [33691] = true, -- Portal: Shattrath
      [35717] = true, -- Portal: Shattrath
    	[176244] = true, -- Portal: Warspear
    	[176246] = true, -- Portal: Stormshield
    }
    
    local AnnouncerBCConsumables = {
      [57426] = true, -- Fish Feast
      [58465] = true, -- Gigantic Feast
      [57301] = true, -- Great Feast
      [58474] = true, -- Small Feast
    }
    
    local AnnouncerCataConsumables = {
      [92649] = true, -- Cauldron of Battle
      [92712] = true, -- Big Cauldron of Battle
      [87915] = true, -- Goblin BBQ
    	[87643] = true, -- Broiled Dragon Feast
    	[87644] = true, -- Seafood Magnifique Feast
    }
    
    local AnnouncerPandaConsumables = {
      [105193] = true, -- Great Pandaren Banquet
    	[104958] = true, -- Pandaren Banquet
    	[145166] = true, -- Noodle Cart
    	[145169] = true, -- Deluxe Noodle Cart
    	[145196] = true, -- Pandaren Treasure Noodle Cart
      [126495] = true, -- Banquet of the Wok
    	[126496] = true, -- Great Banquet of the Wok
      [126499] = true, -- Banquet of the Steamer
    	[126500] = true, -- Great Banquet of the Steamer
      [126497] = true, -- Banquet of the Pot
    	[126498] = true, -- Great Banquet of the Pot
    	[126501] = true, -- Banquet of the Oven
    	[126502] = true, -- Great Banquet of the Oven	
      [126492] = true, -- Banquet of the Grill
    	[126494] = true, -- Great Banquet of the Grill	
      [126503] = true, -- Banquet of the Brew
    	[126504] = true, -- Great Banquet of the Brew
    }
    
    local AnnouncerDraenorConsumables = {
      [185706] = true, -- Fancy Darkmoon Feast
      [160740] = true, -- Feast of Blood
      [160914] = true, -- Feast of the Waters
      [175215] = true, -- Savage Feast
      [185709] = true, -- Sugar-Crusted Fish Feast
    
    }
    local AnnouncerLegionConsumables = {
      [226241] = true, -- Codex of the Tranquil Mind
      [201351] = true, -- Hearty Feast
      [201352] = true, -- Lavish Suramar Feast
      [188036] = true, -- Spirit Cauldron
    }
    
    local AnnouncerClassConsumables = {
      [190336] = true, -- Conjure Refreshment (Mage)
      [29893] = true, -- Create Soulwell (Warlock)
      [83958] = true, -- Mobile Banking (All)
      [698] = true, -- Ritual of Summoning (Warlock)
    }
    
    local AnnouncerEngineering = {
    	[54711] = true, -- Scrapbot
    	[22700] = true, -- Field Repair Bot 74A
    	[44389] = true, -- Field Repair Bot 110G
    	[67826] = true, -- Jeeves
    	[54710] = true, -- MOLL-E aka Mailbox
      [157066] = true, -- Walter
    	[126459] = true, -- Blingtron 4000
      [161414] = true, -- Blingtron 5000
      [200217] = true, -- Blingtron 6000
      [126462] = true, -- Thermal Anvil
    	[199109] = true, -- Auto-hammer
      [199115] = true, -- Failure Detection Pylon
      [200061] = true, -- Summon Reaves
    	[200204] = true, -- Reaves Auto-hammer
    }
    
    local AnnouncerMassRes = {
    	[212040] = true, -- Druid Revitalize
      [212051] = true, -- Monk Reawaken
      [212056] = true, -- Pally Absolution
      [212036] = true, -- Priest Mass Res
      [212048] = true, -- Shaman Ancestral Vision
    }
    
    frame:RegisterEvent("ADDON_LOADED")
    frame:RegisterEvent("PLAYER_LOGIN")
    
    frame:SetScript("OnEvent", function(self, event, ...)
    	if event == "ADDON_LOADED" then
    		if Announcer == nil then
    			Announcer = true
    		end
    		if AnnouncerSay == nil then
    			AnnouncerSay = false
    		end
    		if AnnouncerRW == nil then
    			AnnouncerRW = false
    		end
    		
    		if Announcer == true then
    			frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    		else
    			frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    		end
    
    	else
    		local _, event, _, _, sourceName, _, _, _, _, _, _, spellID, spellName = ...		
    		if (Announcer == true and (UnitInParty(sourceName) or UnitInRaid(sourceName)) and (event=="SPELL_CAST_SUCCESS"  or event=="SPELL_CAST_START") 
    		and GetNumGroupMembers()>0 and (AnnouncerPortals[spellID] or AnnouncerBCConsumables[spellID] or AnnouncerCataConsumables[spellID] or 
    		AnnouncerPandaConsumables[spellID] or AnnouncerDraenorConsumables[spellID] or AnnouncerLegionConsumables[spellID] or 
    		AnnouncerClassConsumables[spellID] or AnnouncerEngineering or AnnouncerMassRes[spellID] 
    		)) then
    			if AnnouncerPortals[spellID] then
    				AnnouncerSpeaks = "> "..sourceName.." set up a "..GetSpellLink(spellID).." <"
    			end
    			if AnnouncerBCConsumables[spellID] then
    				AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
    			end
    			if AnnouncerCataConsumables[spellID] then
    				AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
    			end
          if AnnouncerPandaConsumables[spellID] then
    				AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
    			end
    			if AnnouncerDraenorConsumables[spellID] then
    				AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
    			end
    			if AnnouncerLegionConsumables[spellID] then
    				AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
    			end
    			if AnnouncerClassConsumables[spellID] then
    				AnnouncerSpeaks = "> "..sourceName.." is casting "..GetSpellLink(spellID).." <"
    			end
    			if AnnouncerEngineering[spellID] then
    				AnnouncerSpeaks = "> "..sourceName.." has created a "..GetSpellLink(spellID).." <"
    			end
          if AnnouncerMassRes[spellID] then
    				AnnouncerSpeaks = "> "..sourceName.." is casting "..GetSpellLink(spellID).." <"
    			end
          
    			if (antispam[AnnouncerSpeaks]==nil) then
    				antispam[AnnouncerSpeaks] = time()
    				AnnouncerChatter(AnnouncerSpeaks)
    			elseif (time()-antispam[AnnouncerSpeaks])>12 then
    				antispam[AnnouncerSpeaks] = time()
    				AnnouncerChatter(AnnouncerSpeaks)
    			end
        end
    	end
    end)
    Any help would be appreciated. It's probably a simple fix, but i'm not sure what the problem is.

  2. #2
    The Unstoppable Force Elim Garak's Avatar
    10+ Year Old Account
    Join Date
    Apr 2011
    Location
    DS9
    Posts
    20,297
    AnnouncerClassConsumables[spellID] or AnnouncerEngineering[spellID] or AnnouncerMassRes[spellID]


    Bold is the missing part in your code that makes it repeat the last message on any spell cast in group environment
    All right, gentleperchildren, let's review. The year is 2024 - that's two-zero-two-four, as in the 21st Century's perfect vision - and I am sorry to say the world has become a pussy-whipped, Brady Bunch version of itself, run by a bunch of still-masked clots ridden infertile senile sissies who want the Last Ukrainian to die so they can get on with the War on China, with some middle-eastern genocide on the side

  3. #3
    Fantastic! I knew it was something dumb. Thanks so much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •