-
Posted by tactica on Wed, 19 Mar 2014 21:38:31
Greetings, I am a nub at lua but have made progress this week but...I have been working on trying to update an abandoned addon and have made some progress in tweaking it to look better in the sense that it will place clickable links of the items conjured. I can't for the life of me get the Noodle Carts to work with what I have below.
So The issues are 1) If I add "or type="SPELLCASTSUCCESS" which I referenced from RSA (another addon) for the noodle carts, the addon fails to load entirely.
2) Even when the command "/can group" is entered, unless there are 5 people or an instance, then it will continue to /say the conjured item when grouped with one other person. I would like it to /party the message if it is 2+ and Instance (which it detects fine).
I have posted the entire .lua for reference.
function displayMessage(msg) inInstance, instanceType = IsInInstance()
local messageType = "SAY"
if AnnouncerSay==true then
--
elseif inInstance == 1 and instanceType ~= "none" then
messageType = "INSTANCE_CHAT"
end
if (AnnouncerRW == true and (UnitIsGroupAssistant("player") or UnitIsLeader("player")) and IsInRaid()) then
messageType = "RAID_WARNING"
end
SendChatMessage(msg,messageType) endfunction printMessage(msg) print("|cff7f7fff[Conjured Announcer] "..msg) end
function OnEvent(self, event, ...) if event == "VARIABLES_LOADED" then
if AnnouncerState==nil then AnnouncerState = true end if AnnouncerSay==nil then AnnouncerSay = 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 2 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, sourceGUID,hideCaster, sourceName, sourceFlags,sourceRaidFlags, destGUID, destName, destFlags,destRaidFlags, spellID, spellName = select(1, ...) --print (type,spellID,sourceName,destName,GetSpellLink(spellID)) --printMessage (searchTable) if (AnnouncerState == true and (UnitInParty(sourceName) or UnitInRaid(sourceName)) and (type=="SPELL_CREATE" or type=="SPELL_SUMMON" or type=="SPELL_CAST_START") and GetNumGroupMembers()>0 and checkTable[spellID]~=nil) then --printMessage ("**************") --printMessage (type,spellID,sourceName,GetSpellLink(spellID),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 message = "{rt1}" ..sourceName .. " has created " .. GetSpellLink(spellID).."{rt1}" 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(" Updated for 5.4.7 by Tactica")
printMessage(" Activate : /can on") printMessage(" Deactivate: /can off") printMessage(" Announce on SAY: /can say") printMessage(" Announce on GROUP chat: /can group") printMessage(" Announce on RAID WARNING: /can rw") endfunction 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] == "say") then AnnouncerSay = true printMessage("Announcer set to SAY.") elseif (argv[1] == "rw") then AnnouncerRW = not AnnouncerRW printMessage("Announcer using raidwarning: "..getState(AnnouncerRW)) elseif (argv[1] == "group") then AnnouncerSay = 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 WokspellIDS = {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} 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)
Thanks in advance for the help! Tactica